Enum secret_cosmwasm_std::StdError
source · [−]#[non_exhaustive]
pub enum StdError {
GenericErr {
msg: String,
backtrace: Option<Backtrace>,
},
InvalidBase64 {
msg: String,
backtrace: Option<Backtrace>,
},
InvalidUtf8 {
msg: String,
backtrace: Option<Backtrace>,
},
NotFound {
kind: String,
backtrace: Option<Backtrace>,
},
ParseErr {
target: String,
msg: String,
backtrace: Option<Backtrace>,
},
SerializeErr {
source: String,
msg: String,
backtrace: Option<Backtrace>,
},
Unauthorized {
backtrace: Option<Backtrace>,
},
Underflow {
minuend: String,
subtrahend: String,
backtrace: Option<Backtrace>,
},
}
Expand description
Structured error type for init, handle and query.
This can be serialized and passed over the Wasm/VM boundary, which allows us to use structured error types in e.g. integration tests. In that process backtraces are stripped off.
The prefix “Std” means “the standard error within the standard library”. This is not the only result/error type in cosmwasm-std.
When new cases are added, they should describe the problem rather than what was attempted (e.g. InvalidBase64 is preferred over Base64DecodingErr). In the long run this allows us to get rid of the duplication in “StdError::FooErr”.
Checklist for adding a new error:
- Add enum case
- Add to PartialEq implementation
- Add serialize/deserialize test
- Add creator function in std_error_helpers.rs
- Regenerate schemas
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
GenericErr
Whenever there is no specific error type available
InvalidBase64
InvalidUtf8
Whenever UTF-8 bytes cannot be decoded into a unicode string, e.g. in String::from_utf8 or str::from_utf8.
NotFound
ParseErr
SerializeErr
Unauthorized
Fields
Underflow
Implementations
sourceimpl StdError
impl StdError
pub fn generic_err<S: Into<String>>(msg: S) -> Self
pub fn invalid_base64<S: ToString>(msg: S) -> Self
pub fn invalid_utf8<S: ToString>(msg: S) -> Self
pub fn not_found<S: Into<String>>(kind: S) -> Self
pub fn parse_err<T: Into<String>, M: ToString>(target: T, msg: M) -> Self
pub fn serialize_err<S: Into<String>, M: ToString>(source: S, msg: M) -> Self
pub fn underflow<U: ToString>(minuend: U, subtrahend: U) -> Self
Trait Implementations
sourceimpl<'de> Deserialize<'de> for StdError
impl<'de> Deserialize<'de> for StdError
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Error for StdError where
Self: Debug + Display,
impl Error for StdError where
Self: Debug + Display,
sourcefn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
sourcefn cause(&self) -> Option<&dyn Error>
fn cause(&self) -> Option<&dyn Error>
replaced by Error::source, which can support downcasting
sourceimpl ErrorCompat for StdError
impl ErrorCompat for StdError
sourceimpl JsonSchema for StdError
impl JsonSchema for StdError
sourcefn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
sourcefn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
sourcefn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the $ref
keyword. Read more
sourceimpl PartialEq<StdError> for StdError
impl PartialEq<StdError> for StdError
sourcefn eq(&self, other: &Self) -> bool
fn eq(&self, other: &Self) -> bool
Two errors are considered equal if and only if their payloads (i.e. all fields other than backtrace) are equal.
The origin of the error (expressed by its backtrace) is ignored, which allows equality checks on errors and results in tests. This is a property that might not always be desired depending on the use case and something you should be aware of.
Note: We destruct the unused backtrace as _ to avoid the use of ..
which silently ignores newly added fields.
Auto Trait Implementations
impl RefUnwindSafe for StdError
impl Send for StdError
impl Sync for StdError
impl Unpin for StdError
impl UnwindSafe for StdError
Blanket Implementations
sourceimpl<T> AsErrorSource for T where
T: 'static + Error,
impl<T> AsErrorSource for T where
T: 'static + Error,
sourcefn as_error_source(&self) -> &(dyn Error + 'static)
fn as_error_source(&self) -> &(dyn Error + 'static)
For maximum effectiveness, this needs to be called as a method to benefit from Rust’s automatic dereferencing of method receivers. Read more
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more