use jsonrpsee::types::error::{ErrorObject, ErrorObjectOwned};
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("This storage kind is not available yet.")]
UnavailableStorageKind,
#[error(transparent)]
UnsafeRpcCalled(#[from] crate::policy::UnsafeRpcError),
}
const BASE_ERROR: i32 = crate::error::base::OFFCHAIN;
impl From<Error> for ErrorObjectOwned {
fn from(e: Error) -> Self {
match e {
Error::UnavailableStorageKind => ErrorObject::owned(
BASE_ERROR + 1,
"This storage kind is not available yet",
None::<()>,
),
Error::UnsafeRpcCalled(e) => e.into(),
}
}
}