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
use alloc::{format, string::String};

use crate::extension::PolymeshRuntimeErr;

use codec::{Decode, Encode};

#[derive(Debug, Encode, Decode)]
#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
pub enum Error {
  ParityScaleCodec(String),
  RuntimeError(PolymeshRuntimeErr),
}

impl From<PolymeshRuntimeErr> for Error {
  fn from(err: PolymeshRuntimeErr) -> Self {
    Self::RuntimeError(err)
  }
}

impl From<codec::Error> for Error {
  fn from(err: codec::Error) -> Self {
    Self::ParityScaleCodec(format!("{err:?}"))
  }
}

pub type Result<T, E = Error> = core::result::Result<T, E>;