2022-09-29 23:35:43 +00:00
|
|
|
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)]
|
2022-10-25 23:10:49 +00:00
|
|
|
#[error("rpc error on method: {method}, message: {error}")]
|
|
|
|
pub struct RpcError<E: ToString> {
|
2022-10-13 17:59:37 +00:00
|
|
|
method: String,
|
2022-10-25 23:10:49 +00:00
|
|
|
error: E,
|
2022-09-29 23:35:43 +00:00
|
|
|
}
|
|
|
|
|
2022-10-25 23:10:49 +00:00
|
|
|
impl<E: ToString> RpcError<E> {
|
|
|
|
pub fn new(method: &str, err: E) -> Self {
|
2022-10-13 17:59:37 +00:00
|
|
|
Self {
|
|
|
|
method: method.to_string(),
|
2022-10-25 23:10:49 +00:00
|
|
|
error: err,
|
2022-10-13 17:59:37 +00:00
|
|
|
}
|
2022-09-29 23:35:43 +00:00
|
|
|
}
|
|
|
|
}
|