use thiserror instead of derive_more for error handling (#10696)

* use thiserror instead of derive_more for error handling

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Update utils/prometheus/src/lib.rs

* Update utils/prometheus/src/lib.rs

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Qinxuan Chen
2022-01-26 03:48:46 +08:00
committed by GitHub
parent 38d94d6323
commit e956c2e1c7
47 changed files with 378 additions and 357 deletions
+19 -9
View File
@@ -125,28 +125,38 @@ impl From<String> for Error {
}
/// Type for errors occurring during Wasm runtime construction.
#[derive(Debug, derive_more::Display)]
#[derive(Debug, thiserror::Error)]
#[allow(missing_docs)]
pub enum WasmError {
/// Code could not be read from the state.
#[error("Code could not be read from the state.")]
CodeNotFound,
/// Failure to reinitialize runtime instance from snapshot.
#[error("Failure to reinitialize runtime instance from snapshot.")]
ApplySnapshotFailed,
/// Failure to erase the wasm memory.
///
/// Depending on the implementation might mean failure of allocating memory.
#[error("Failure to erase the wasm memory: {0}")]
ErasingFailed(String),
/// Wasm code failed validation.
#[error("Wasm code failed validation.")]
InvalidModule,
/// Wasm code could not be deserialized.
#[error("Wasm code could not be deserialized.")]
CantDeserializeWasm,
/// The module does not export a linear memory named `memory`.
#[error("The module does not export a linear memory named `memory`.")]
InvalidMemory,
/// The number of heap pages requested is disallowed by the module.
#[error("The number of heap pages requested is disallowed by the module.")]
InvalidHeapPages,
/// Instantiation error.
#[error("{0}")]
Instantiation(String),
/// Other error happenend.
#[error("{0}")]
Other(String),
}
impl std::error::Error for WasmError {}