aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/format/msgpack.rs4
-rw-r--r--src/lib.rs13
-rw-r--r--src/main.rs2
3 files changed, 15 insertions, 4 deletions
diff --git a/src/format/msgpack.rs b/src/format/msgpack.rs
index 3519b76..d823a6d 100644
--- a/src/format/msgpack.rs
+++ b/src/format/msgpack.rs
@@ -34,14 +34,14 @@ impl<'a, R: 'a> Iterator for Iter<'a, R> where R: BufRead {
type Item = ::Result<Event<'a>>;
fn next(&mut self) -> Option<::Result<Event<'a>>> {
Some(Decodable::decode(&mut Decoder::new(&mut self.input))
- .map_err(|_| ::IlcError::BincodeDecode))
+ .map_err(|e| ::IlcError::MsgpackDecode(e)))
}
}
impl<'a, W> Encode<'a, W> for Msgpack where W: Write {
fn encode(&'a self, _context: &'a Context, mut output: W, event: &'a Event) -> ::Result<()> {
event.encode(&mut Encoder::new(&mut output))
- .map_err(|_| ::IlcError::BincodeEncode)
+ .map_err(|e| ::IlcError::MsgpackEncode(e))
}
}
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)
}
}
}
diff --git a/src/main.rs b/src/main.rs
index 81cfbd9..aa39b69 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -208,7 +208,7 @@ fn main() {
for e in decoder.decode_box(&context, &mut input) {
let m = match e {
Ok(m) => m,
- Err(err) => panic!(err)
+ Err(err) => error(Box::new(err))
};
match m {