clay_core/
error.rs

1use std::io;
2use std::fmt;
3
4use ocl;
5
6
7#[derive(Debug)]
8pub enum Error {
9    Io(io::Error),
10    Ocl(ocl::Error),
11    Other(String),
12}
13
14impl fmt::Display for Error {
15    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
16        match self {
17            Error::Io(e) => write!(f, "Io: {:?}\n{}", e.kind(), e),
18            Error::Ocl(e) => write!(f, "Ocl:\n{}", e),
19            Error::Other(s) => write!(f, "Other:\n{}", s),
20        }
21    }
22}
23
24impl From<io::Error> for Error {
25    fn from(e: io::Error) -> Self {
26        Error::Io(e)
27    }
28}
29
30impl From<ocl::Error> for Error {
31    fn from(e: ocl::Error) -> Self {
32        Error::Ocl(e)
33    }
34}
35
36impl From<String> for Error {
37    fn from(s: String) -> Self {
38        Error::Other(s)
39    }
40}
41
42impl From<&str> for Error {
43    fn from(s: &str) -> Self {
44        Error::Other(s.to_string())
45    }
46}