2 use core::fmt::Formatter;
3 use lightning::ln::msgs::{DecodeError, LightningError};
5 /// All-encompassing standard error type that processing can return
6 pub enum GraphSyncError {
7 /// Error trying to read the update data, typically due to an erroneous data length indication
8 /// that is greater than the actual amount of data provided
9 DecodeError(DecodeError),
10 /// Error applying the patch to the network graph, usually the result of updates that are too
11 /// old or missing prerequisite data to the application of updates out of order
12 LightningError(LightningError),
15 impl From<lightning::io::Error> for GraphSyncError {
16 fn from(error: lightning::io::Error) -> Self {
17 Self::DecodeError(DecodeError::Io(error.kind()))
21 impl From<DecodeError> for GraphSyncError {
22 fn from(error: DecodeError) -> Self {
23 Self::DecodeError(error)
27 impl From<LightningError> for GraphSyncError {
28 fn from(error: LightningError) -> Self {
29 Self::LightningError(error)
33 impl Debug for GraphSyncError {
34 fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
36 GraphSyncError::DecodeError(e) => f.write_fmt(format_args!("DecodeError: {:?}", e)),
37 GraphSyncError::LightningError(e) => f.write_fmt(format_args!("LightningError: {:?}", e))