@@ -49,38 +49,41 @@ use traits::TskTeardown;
4949#[ derive( Debug ) ]
5050pub enum TskitError {
5151 /// Returned when conversion attempts fail
52- //#[error("range error: {}", *.0)]
5352 RangeError ( String ) ,
5453 /// Used when bad input is encountered.
55- //#[error("we received {} but expected {}",*got, *expected)]
5654 ValueError { got : String , expected : String } ,
5755 /// Used when array access is out of range.
5856 /// Typically, this is used when accessing
5957 /// arrays allocated on the C side.
60- //#[error("Invalid index")]
6158 IndexError ,
6259 /// Raised when samples are requested from
6360 /// [`crate::Tree`] objects, but sample lists are
6461 /// not being updated.
65- //#[error("Not tracking samples in Trees")]
6662 NotTrackingSamples ,
6763 /// Wrapper around tskit C API error codes.
68- //#[error("{}", get_tskit_error_message(*code))]
6964 ErrorCode { code : i32 } ,
7065 /// A redirection of [``crate::metadata::MetadataError``]
71- //#[error("{value:?}")]
7266 MetadataError {
7367 /// The redirected error
7468 value : MetadataError ,
7569 } ,
7670 /// General error variant
77- //#[error("{}", *.0)]
7871 LibraryError ( String ) ,
7972}
8073
8174impl std:: fmt:: Display for TskitError {
8275 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
83- todo ! ( )
76+ match self {
77+ Self :: RangeError ( msg) => write ! ( f, "range error: {}" , msg) ,
78+ Self :: ValueError { got, expected } => {
79+ write ! ( f, "we received {} but expected {}" , got, expected)
80+ }
81+ Self :: IndexError => write ! ( f, "Invalid index" ) ,
82+ Self :: NotTrackingSamples => write ! ( f, "Not tracking samples in Trees" ) ,
83+ Self :: ErrorCode { code } => write ! ( f, "{}" , get_tskit_error_message( * code) ) ,
84+ Self :: MetadataError { value } => write ! ( f, "meta data error: {}" , value) ,
85+ Self :: LibraryError ( msg) => write ! ( f, "library error: {msg}" ) ,
86+ }
8487 }
8588}
8689
@@ -97,15 +100,16 @@ impl std::error::Error for TskitError {}
97100pub enum MetadataError {
98101 /// Error related to types implementing
99102 /// metadata serialization.
100- // #[error("{}", *value)]
101103 RoundtripError {
102104 value : Box < dyn std:: error:: Error + Send + Sync > ,
103105 } ,
104106}
105107
106108impl std:: fmt:: Display for MetadataError {
107109 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
108- todo ! ( )
110+ match self {
111+ Self :: RoundtripError { value } => write ! ( f, "meta data round trip error: {value:?}" ) ,
112+ }
109113 }
110114}
111115
0 commit comments