impl Error for error types
This commit is contained in:
parent
e61244bce3
commit
bac34e94c5
3 changed files with 54 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
|||
use std::{
|
||||
error::Error,
|
||||
fmt::{Display, Formatter, Result as FmtResult}
|
||||
};
|
||||
|
||||
use bytes::BytesMut;
|
||||
use bytes::BufMut;
|
||||
use futures::Async;
|
||||
|
@ -12,6 +17,19 @@ pub enum ParsingError<E> {
|
|||
EbmlError(EbmlError),
|
||||
OtherError(E)
|
||||
}
|
||||
impl<E: Display + Error> Display for ParsingError<E> {
|
||||
fn fmt(&self, f: &mut Formatter) -> FmtResult {
|
||||
write!(f, "Parsing error: {}", self.description())
|
||||
}
|
||||
}
|
||||
impl<E: Error> Error for ParsingError<E> {
|
||||
fn description(&self) -> &str {
|
||||
match self {
|
||||
&ParsingError::EbmlError(ref err) => err.description(),
|
||||
&ParsingError::OtherError(ref err) => err.description()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct EbmlStreamingParser<S> {
|
||||
stream: S,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue