drink/
errors.rs

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