helios/common/src/errors.rs

32 lines
605 B
Rust

use thiserror::Error;
use crate::types::BlockTag;
#[derive(Debug, Error)]
#[error("block not available: {block}")]
pub struct BlockNotFoundError {
block: BlockTag,
}
impl BlockNotFoundError {
pub fn new(block: BlockTag) -> Self {
Self { block }
}
}
#[derive(Debug, Error)]
#[error("rpc error on method: {method}, message: {error}")]
pub struct RpcError<E: ToString> {
method: String,
error: E,
}
impl<E: ToString> RpcError<E> {
pub fn new(method: &str, err: E) -> Self {
Self {
method: method.to_string(),
error: err,
}
}
}