File tree Expand file tree Collapse file tree 6 files changed +37
-59
lines changed Expand file tree Collapse file tree 6 files changed +37
-59
lines changed Original file line number Diff line number Diff line change @@ -17,4 +17,5 @@ default = []
17
17
byteorder = " 1.0"
18
18
flate2 = { version = " 0.2" , features = [" zlib" ], default-features = false }
19
19
uuid = { version = " 0.5" , optional = true }
20
+ error-chain = " 0.10"
20
21
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ use std;
2
+
3
+ error_chain ! {
4
+ types {
5
+ Error , ErrorKind , ResultExt ;
6
+ }
7
+
8
+ foreign_links {
9
+ Io ( std:: io:: Error ) ;
10
+ FromUtf8 ( std:: string:: FromUtf8Error ) ;
11
+ TryFromIntError ( std:: num:: TryFromIntError ) ;
12
+ CharTryFromError ( std:: char :: CharTryFromError ) ;
13
+
14
+ UuidParseError ( :: uuid:: ParseError ) #[ cfg( feature = "uuid" ) ] ;
15
+ }
16
+
17
+ errors {
18
+ UnknownPacketId {
19
+ description( "unknown packet identifier" )
20
+ display( "unknown packet identifier" )
21
+ }
22
+ }
23
+ }
24
+
Original file line number Diff line number Diff line change 7
7
8
8
pub use self :: primitives:: { Integer , DynArray , String } ;
9
9
pub use self :: parcel:: Parcel ;
10
- pub use self :: error :: Error ;
10
+ pub use self :: errors :: { Error , ErrorKind , ResultExt } ;
11
11
12
+ // Must go first because it defines common macros.
12
13
#[ macro_use]
13
- pub mod primitives ;
14
+ mod packet ;
14
15
15
- mod parcel;
16
16
#[ macro_use]
17
- mod packet;
18
- mod error;
17
+ pub mod primitives;
19
18
#[ macro_use]
20
19
pub mod wire;
21
20
21
+ mod errors;
22
+ mod parcel;
23
+
22
24
extern crate byteorder;
23
25
extern crate flate2;
26
+ #[ macro_use]
27
+ extern crate error_chain;
24
28
25
29
#[ cfg( feature = "uuid" ) ]
26
30
extern crate uuid;
Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ macro_rules! define_packet_kind
80
80
81
81
let packet = match packet_id {
82
82
$( $packet_id => $ty:: $packet_ty( <$packet_ty as $crate:: Parcel >:: read( read) ?) , ) +
83
- _ => return Err ( $crate:: Error :: UnknownPacketId ) ,
83
+ _ => return Err ( $crate:: ErrorKind :: UnknownPacketId . into ( ) ) ,
84
84
} ;
85
85
86
86
Ok ( packet)
Original file line number Diff line number Diff line change 1
1
#[ macro_use]
2
- pub mod macros;
2
+ mod macros;
3
3
#[ cfg( test) ]
4
4
#[ allow( unused_variables) ]
5
- pub mod test;
5
+ mod test;
6
6
You can’t perform that action at this time.
0 commit comments