pub enum StdError {
Show 13 variants
VerificationErr {
source: VerificationError,
backtrace: BT,
},
RecoverPubkeyErr {
source: RecoverPubkeyError,
backtrace: BT,
},
GenericErr {
msg: String,
backtrace: BT,
},
InvalidBase64 {
msg: String,
backtrace: BT,
},
InvalidDataSize {
expected: u64,
actual: u64,
backtrace: BT,
},
InvalidHex {
msg: String,
backtrace: BT,
},
InvalidUtf8 {
msg: String,
backtrace: BT,
},
NotFound {
kind: String,
backtrace: BT,
},
ParseErr {
target_type: String,
msg: String,
backtrace: BT,
},
SerializeErr {
source_type: String,
msg: String,
backtrace: BT,
},
Overflow {
source: OverflowError,
backtrace: BT,
},
DivideByZero {
source: DivideByZeroError,
backtrace: BT,
},
ConversionOverflow {
source: ConversionOverflowError,
backtrace: BT,
},
}
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
RecoverPubkeyErr
GenericErr
Whenever there is no specific error type available
InvalidBase64
InvalidDataSize
InvalidHex
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
Overflow
DivideByZero
ConversionOverflow
Implementations§
Source§impl 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_hex(msg: impl ToString) -> 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§
Source§impl Error for StdError
impl Error for StdError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<CoinFromStrError> for StdError
impl From<CoinFromStrError> for StdError
Source§fn from(value: CoinFromStrError) -> Self
fn from(value: CoinFromStrError) -> Self
Source§impl From<CoinsError> for StdError
impl From<CoinsError> for StdError
Source§fn from(value: CoinsError) -> Self
fn from(value: CoinsError) -> Self
Source§impl From<ConversionOverflowError> for StdError
impl From<ConversionOverflowError> for StdError
Source§fn from(err: ConversionOverflowError) -> Self
fn from(err: ConversionOverflowError) -> Self
Source§impl From<DivideByZeroError> for StdError
impl From<DivideByZeroError> for StdError
Source§fn from(source: DivideByZeroError) -> Self
fn from(source: DivideByZeroError) -> Self
Source§impl From<FromUtf8Error> for StdError
impl From<FromUtf8Error> for StdError
Source§fn from(source: FromUtf8Error) -> Self
fn from(source: FromUtf8Error) -> Self
Source§impl From<OverflowError> for StdError
impl From<OverflowError> for StdError
Source§fn from(source: OverflowError) -> Self
fn from(source: OverflowError) -> Self
Source§impl From<RecoverPubkeyError> for StdError
impl From<RecoverPubkeyError> for StdError
Source§fn from(source: RecoverPubkeyError) -> Self
fn from(source: RecoverPubkeyError) -> Self
Source§impl From<VerificationError> for StdError
impl From<VerificationError> for StdError
Source§fn from(source: VerificationError) -> Self
fn from(source: VerificationError) -> Self
Auto Trait Implementations§
impl Freeze for StdError
impl !RefUnwindSafe for StdError
impl Send for StdError
impl Sync for StdError
impl Unpin for StdError
impl !UnwindSafe for StdError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more