Enum cosmwasm_std::StdError
source · [−]pub enum StdError {
VerificationErr {
source: VerificationError,
},
RecoverPubkeyErr {
source: RecoverPubkeyError,
},
GenericErr {
msg: String,
},
InvalidBase64 {
msg: String,
},
InvalidDataSize {
expected: u64,
actual: u64,
},
InvalidUtf8 {
msg: String,
},
NotFound {
kind: String,
},
ParseErr {
target_type: String,
msg: String,
},
SerializeErr {
source_type: String,
msg: String,
},
Overflow {
source: OverflowError,
},
DivideByZero {
source: DivideByZeroError,
},
ConversionOverflow {
source: ConversionOverflowError,
},
}
Expand description
Structured error type for init, execute 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 creator function in std_error_helpers.rs
Variants
VerificationErr
Fields
source: VerificationError
RecoverPubkeyErr
Fields
source: RecoverPubkeyError
GenericErr
Fields
msg: String
Whenever there is no specific error type available
InvalidBase64
Fields
msg: String
InvalidDataSize
InvalidUtf8
Fields
msg: String
Whenever UTF-8 bytes cannot be decoded into a unicode string, e.g. in String::from_utf8 or str::from_utf8.
NotFound
Fields
kind: String
ParseErr
SerializeErr
Overflow
Fields
source: OverflowError
DivideByZero
Fields
source: DivideByZeroError
ConversionOverflow
Fields
source: ConversionOverflowError
Implementations
sourceimpl StdError
impl StdError
pub fn verification_err(source: VerificationError) -> Self
pub fn recover_pubkey_err(source: RecoverPubkeyError) -> Self
pub fn generic_err(msg: impl Into<String>) -> Self
pub fn invalid_base64(msg: impl ToString) -> Self
pub fn invalid_data_size(expected: usize, actual: usize) -> Self
pub fn invalid_utf8(msg: impl ToString) -> Self
pub fn not_found(kind: impl Into<String>) -> Self
pub fn parse_err(target: impl Into<String>, msg: impl ToString) -> Self
pub fn serialize_err(source: impl Into<String>, msg: impl ToString) -> Self
pub fn overflow(source: OverflowError) -> Self
pub fn divide_by_zero(source: DivideByZeroError) -> Self
Trait Implementations
sourceimpl Error for StdError
impl Error for StdError
sourcefn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
sourcefn backtrace(&self) -> Option<&Backtrace>
fn backtrace(&self) -> Option<&Backtrace>
backtrace
)Returns a stack backtrace, if available, of where this error occurred. Read more
1.0.0 · sourcefn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
sourceimpl From<ConversionOverflowError> for StdError
impl From<ConversionOverflowError> for StdError
sourcefn from(source: ConversionOverflowError) -> Self
fn from(source: ConversionOverflowError) -> Self
Converts to this type from the input type.
sourceimpl From<DivideByZeroError> for StdError
impl From<DivideByZeroError> for StdError
sourcefn from(source: DivideByZeroError) -> Self
fn from(source: DivideByZeroError) -> Self
Converts to this type from the input type.
sourceimpl From<FromUtf8Error> for StdError
impl From<FromUtf8Error> for StdError
sourcefn from(source: FromUtf8Error) -> Self
fn from(source: FromUtf8Error) -> Self
Converts to this type from the input type.
sourceimpl From<OverflowError> for StdError
impl From<OverflowError> for StdError
sourcefn from(source: OverflowError) -> Self
fn from(source: OverflowError) -> Self
Converts to this type from the input type.
sourceimpl From<RecoverPubkeyError> for StdError
impl From<RecoverPubkeyError> for StdError
sourcefn from(source: RecoverPubkeyError) -> Self
fn from(source: RecoverPubkeyError) -> Self
Converts to this type from the input type.
sourceimpl From<VerificationError> for StdError
impl From<VerificationError> for StdError
sourcefn from(source: VerificationError) -> Self
fn from(source: VerificationError) -> Self
Converts to this type from the input type.
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> 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