From 01703f2dcd807f58c03a83bf1d3fa52e8023a0ad Mon Sep 17 00:00:00 2001 From: Till Hoeppner Date: Tue, 28 Jul 2015 00:35:57 +0200 Subject: Improved error reporting --- src/lib.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index c817e6c..422ca07 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,6 +41,8 @@ pub enum IlcError { Chrono(ParseError), BincodeDecode, BincodeEncode, + MsgpackEncode(msgpack::encode::serialize::Error), + MsgpackDecode(msgpack::decode::serialize::Error), Io(io::Error) } @@ -58,13 +60,22 @@ impl Error for IlcError { &Chrono(_) => "error while parsing time strings", &BincodeDecode => "error while decoding from binary", &BincodeEncode => "error while encoding to binary", + &MsgpackDecode(_) => "error while decoding from msgpack", + &MsgpackEncode(_) => "error while encoding to msgpack", &Io(_) => "error during input/output" } } fn cause(&self) -> Option<&Error> { + use IlcError::*; match self { - _ => None + &Parse(ref _e) => None, + &Chrono(ref e) => Some(e), + &BincodeDecode => None, + &BincodeEncode => None, + &MsgpackDecode(ref e) => Some(e), + &MsgpackEncode(ref e) => Some(e), + &Io(ref e) => Some(e) } } } -- cgit v1.2.3