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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use ckb_channel::oneshot::RecvError;
use ckb_error::{
impl_error_conversion_with_adaptor, impl_error_conversion_with_kind, prelude::*, Error,
InternalError, InternalErrorKind, OtherError,
};
pub use ckb_types::core::tx_pool::Reject;
use tokio::sync::mpsc::error::TrySendError;
#[derive(Error, Debug, PartialEq, Clone, Eq)]
pub enum BlockAssemblerError {
#[error("InvalidInput")]
InvalidInput,
#[error("InvalidParams {0}")]
InvalidParams(String),
#[error("Disabled")]
Disabled,
}
impl_error_conversion_with_kind!(
BlockAssemblerError,
InternalErrorKind::BlockAssembler,
InternalError
);
impl_error_conversion_with_adaptor!(BlockAssemblerError, InternalError, Error);
pub(crate) fn handle_try_send_error<T>(error: TrySendError<T>) -> (T, OtherError) {
let e = OtherError::new(format!("TrySendError {}", error));
let m = match error {
TrySendError::Full(t) | TrySendError::Closed(t) => t,
};
(m, e)
}
pub(crate) fn handle_recv_error(error: RecvError) -> OtherError {
OtherError::new(format!("RecvError {}", error))
}
pub(crate) fn handle_send_cmd_error<T>(error: ckb_channel::TrySendError<T>) -> OtherError {
OtherError::new(format!("send command fails: {}", error))
}