1use crate::String;
2use gear_core_errors::ErrorReplyReason;
3#[cfg(feature = "gstd")]
4use gstd::errors::{CoreError as GCoreError, Error as GStdError};
5use parity_scale_codec::Error as CodecError;
6
7pub type Result<T, E = Error> = core::result::Result<T, E>;
8
9#[derive(Debug, thiserror::Error)]
10pub enum Error {
11 #[error("rtl: {0}")]
12 Rtl(#[from] RtlError),
13 #[cfg(feature = "gstd")]
14 #[error("gstd: {0}")]
15 GStd(#[from] GStdError),
16 #[cfg(feature = "gstd")]
17 #[error("gcore: {0}")]
18 GCore(#[from] GCoreError),
19 #[error("codec: {0}")]
20 Codec(CodecError),
21 #[cfg(feature = "gclient")]
22 #[cfg(not(target_arch = "wasm32"))]
23 #[error("gclient: {0}")]
24 GClient(#[from] gclient::Error),
25}
26
27#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
28pub enum RtlError {
29 #[error("type `{type_name}` used as event type must be a enum")]
30 EventTypeMustBeEnum { type_name: String },
31 #[error("reply prefix mismatches")]
32 ReplyPrefixMismatches, #[error("reply is missing")]
34 ReplyIsMissing,
35 #[error("reply is ambiguous")]
36 ReplyIsAmbiguous,
37 #[error("reply code is missing")]
38 ReplyCodeIsMissing,
39 #[error("reply error: {0}")]
40 ReplyHasError(ErrorReplyReason, crate::Vec<u8>),
41 #[error("program code is not found")]
42 ProgramCodeIsNotFound,
43 #[error("program is not found")]
44 ProgramIsNotFound,
45 #[error("reply has error string")]
46 ReplyHasErrorString(String),
47 #[error("event name is not found")]
48 EventNameIsNotFound,
49 #[error("event is not found")]
50 EventIsNotFound,
51 #[error("event prefix mismatches")]
52 EventPrefixMismatches,
53 #[error("invocation prefix mismatches")]
54 InvocationPrefixMismatches,
55}