@@ -5,31 +5,43 @@ mod connection_error;
55pub use cme_error:: CmeError ;
66pub use cms_error:: CmsError ;
77pub use connection_error:: ConnectionError ;
8+ use thiserror:: Error ;
89
910/// Errors returned used internally within the crate
10- #[ derive( Clone , Debug , PartialEq , Eq ) ]
11+ #[ derive( Clone , Debug , PartialEq , Eq , Error ) ]
1112pub enum InternalError < ' a > {
1213 /// Serial read error
14+ #[ error( "Serial read error" ) ]
1315 Read ,
1416 /// Serial write error
17+ #[ error( "Serial write error" ) ]
1518 Write ,
1619 /// Timed out while waiting for a response
20+ #[ error( "Timed out while waiting for a response" ) ]
1721 Timeout ,
1822 /// Invalid response from module
23+ #[ error( "Invalid response from module" ) ]
1924 InvalidResponse ,
2025 /// Command was aborted
26+ #[ error( "Command was aborted" ) ]
2127 Aborted ,
2228 /// Failed to parse received response
29+ #[ error( "Failed to parse received response" ) ]
2330 Parse ,
2431 /// Error response containing any error message
32+ #[ error( "Generic error response" ) ]
2533 Error ,
2634 /// GSM Equipment related error
35+ #[ error( "GSM Equipment related error" ) ]
2736 CmeError ( CmeError ) ,
2837 /// GSM Network related error
38+ #[ error( "GSM Network related error" ) ]
2939 CmsError ( CmsError ) ,
3040 /// Connection Error
41+ #[ error( "Connection Error" ) ]
3142 ConnectionError ( ConnectionError ) ,
3243 /// Custom error match
44+ #[ error( "Custom error match: {0:?}" ) ]
3345 Custom ( & ' a [ u8 ] ) ,
3446}
3547
@@ -57,32 +69,44 @@ impl<'a> defmt::Format for InternalError<'a> {
5769}
5870
5971/// Errors returned by the crate
60- #[ derive( Clone , Debug , PartialEq , Eq ) ]
72+ #[ derive( Clone , Debug , PartialEq , Eq , Error ) ]
6173#[ cfg_attr( feature = "defmt" , derive( defmt:: Format ) ) ]
6274pub enum Error {
6375 /// Serial read error
76+ #[ error( "Serial read error" ) ]
6477 Read ,
6578 /// Serial write error
79+ #[ error( "Serial write error" ) ]
6680 Write ,
6781 /// Timed out while waiting for a response
82+ #[ error( "Timed out while waiting for a response" ) ]
6883 Timeout ,
6984 /// Invalid response from module
85+ #[ error( "Invalid response from module" ) ]
7086 InvalidResponse ,
7187 /// Command was aborted
88+ #[ error( "Command was aborted" ) ]
7289 Aborted ,
7390 /// Failed to parse received response
91+ #[ error( "Failed to parse received response" ) ]
7492 Parse ,
7593 /// Generic error response without any error message
94+ #[ error( "Generic error response" ) ]
7695 Error ,
7796 /// GSM Equipment related error
97+ #[ error( "GSM Equipment related error" ) ]
7898 CmeError ( CmeError ) ,
7999 /// GSM Network related error
100+ #[ error( "GSM Network related error" ) ]
80101 CmsError ( CmsError ) ,
81102 /// Connection Error
103+ #[ error( "Connection Error" ) ]
82104 ConnectionError ( ConnectionError ) ,
83105 /// Error response containing any error message
106+ #[ error( "Custom error response" ) ]
84107 Custom ,
85108 #[ cfg( feature = "custom-error-messages" ) ]
109+ #[ error( "Error response containing any error message {0:?}" ) ]
86110 CustomMessage ( heapless:: Vec < u8 , 64 > ) ,
87111}
88112
0 commit comments