Implemented Error trait.
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+use std::error;
use std::fmt;
use inputs::{Input, position, Position, Span};
@@ -196,6 +197,19 @@ impl<R: fmt::Debug, I: Input> fmt::Display for Error<R, I> {
}
}
+impl<R: fmt::Debug, I: Input> error::Error for Error<R, I> {
+ fn description(&self) -> &str {
+ match *self {
+ Error::ParsingError { ref positives, ref negatives, .. } => {
+ "parsing error"
+ }
+ Error::CustomErrorPos { ref message, .. } | Error::CustomErrorSpan { ref message, .. } => {
+ message
+ }
+ }
+ }
+}
+
#[cfg(test)]
mod tests {
use std::rc::Rc;
