1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
//! Module gathering common error and result types.
use thiserror::Error;
/// Main error type for the drink crate.
#[derive(Error, Debug)]
pub enum Error {
/// Externalities could not be initialized.
#[error("Failed to build storage: {0}")]
StorageBuilding(String),
/// Block couldn't have been initialized.
#[error("Failed to initialize block: {0}")]
BlockInitialize(String),
/// Block couldn't have been finalized.
#[error("Failed to finalize block: {0}")]
BlockFinalize(String),
/// Bundle loading and parsing has failed
#[error("Loading the contract bundle has failed: {0}")]
BundleLoadFailed(String),
}
/// Every contract message wraps its return value in `Result<T, LangResult>`. This is the error
/// type.
///
/// Copied from ink primitives.
#[non_exhaustive]
#[repr(u32)]
#[derive(
Debug,
Copy,
Clone,
PartialEq,
Eq,
parity_scale_codec::Encode,
parity_scale_codec::Decode,
scale_info::TypeInfo,
Error,
)]
pub enum LangError {
/// Failed to read execution input for the dispatchable.
#[error("Failed to read execution input for the dispatchable.")]
CouldNotReadInput = 1u32,
}
/// The `Result` type for ink! messages.
pub type MessageResult<T> = Result<T, LangError>;