1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use std::fmt::{self, Display, Formatter};
use failure::{Backtrace, Fail};
use crate::location::Location;
#[derive(Debug)]
pub struct Error<E: Fail, L: Location> {
pub error: E,
pub location: L,
}
impl<E: Fail, L: Location> Fail for Error<E, L> {
fn name(&self) -> Option<&str> {
self.error.name()
}
fn cause(&self) -> Option<&Fail> {
self.error.cause()
}
fn backtrace(&self) -> Option<&Backtrace> {
self.error.backtrace()
}
}
impl<E: Fail, L: Location> Display for Error<E, L> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
self.location.fmt_error(f, &self.error)
}
}