1use core::str::Utf8Error;
2use std::fmt::Debug;
3use std::string::FromUtf8Error;
4use thiserror::Error;
5
6use hex::FromHexError;
7
8#[derive(Debug, Error)]
9pub enum OperationError {
10 #[error("Utf8 decode error")]
11 DecodeUtf8Error,
12
13 #[error("Decode error")]
14 DecodeError(String),
15}
16
17impl From<Utf8Error> for OperationError {
18 fn from(_value: Utf8Error) -> Self {
19 OperationError::DecodeUtf8Error
20 }
21}
22
23impl From<FromUtf8Error> for OperationError {
24 fn from(_value: FromUtf8Error) -> Self {
25 OperationError::DecodeUtf8Error
26 }
27}
28
29impl From<FromHexError> for OperationError {
30 fn from(_value: FromHexError) -> Self {
31 OperationError::DecodeError("Invalid Hex input".to_string())
32 }
33}