gnuplot/
error_types.rs1use std::error;
2use std::fmt;
3use std::io;
4
5pub struct GnuplotInitError
6{
7 inner: Box<dyn error::Error + 'static + Send + Sync>,
8}
9
10impl From<io::Error> for GnuplotInitError
11{
12 fn from(error: io::Error) -> Self
13 {
14 GnuplotInitError {
15 inner: Box::new(error),
16 }
17 }
18}
19
20impl fmt::Display for GnuplotInitError
21{
22 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result
23 {
24 write!(
25 f,
26 "Couldn't spawn gnuplot. Make sure it is installed and available in PATH.\nCause: {}",
27 self.inner
28 )
29 }
30}
31
32impl fmt::Debug for GnuplotInitError
33{
34 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result
35 {
36 write!(f, "{}", self)
37 }
38}
39
40impl error::Error for GnuplotInitError
41{
42 fn source(&self) -> Option<&(dyn error::Error + 'static)>
43 {
44 Some(&*self.inner)
45 }
46}