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
use core::fmt::Debug;
use core::fmt::Formatter;
use lightning::ln::msgs::{DecodeError, LightningError};
pub enum GraphSyncError {
DecodeError(DecodeError),
LightningError(LightningError),
}
impl From<lightning::io::Error> for GraphSyncError {
fn from(error: lightning::io::Error) -> Self {
Self::DecodeError(DecodeError::Io(error.kind()))
}
}
impl From<DecodeError> for GraphSyncError {
fn from(error: DecodeError) -> Self {
Self::DecodeError(error)
}
}
impl From<LightningError> for GraphSyncError {
fn from(error: LightningError) -> Self {
Self::LightningError(error)
}
}
impl Debug for GraphSyncError {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
match self {
GraphSyncError::DecodeError(e) => f.write_fmt(format_args!("DecodeError: {:?}", e)),
GraphSyncError::LightningError(e) => f.write_fmt(format_args!("LightningError: {:?}", e))
}
}
}