1use std::fmt;
2use std::error::Error;
3
4#[cfg(feature = "gpu_accel")]
5use opencl3::error_codes::ClError;
6
7#[derive(Debug)]
9pub enum Jeeperr {
10 ArgumentError,
12 DimensionError,
14 IndexError,
16 MemoryError,
18 OutputError,
20 #[cfg(feature = "gpu_accel")] ClError(ClError),
22 Error(String)
24}
25
26impl fmt::Display for Jeeperr {
27 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
28 match self {
29 Jeeperr::ArgumentError =>
30 write!(f, "Too many or too few arguments provided"),
31 Jeeperr::DimensionError =>
32 write!(f, "Invalid matrix dimensions for requested operation"),
33 Jeeperr::IndexError =>
34 write!(f, "Invalid index for requested operation"),
35 Jeeperr::MemoryError =>
36 write!(f, "Calculator and Handler have inconsistent memory"),
37 Jeeperr::OutputError =>
38 write!(f, "Invalid output type"),
39 #[cfg(feature = "gpu_accel")] Jeeperr::ClError(error) =>
40 write!(f, "{}", error),
41 Jeeperr::Error(error) =>
42 write!(f, "{}", error)
43 }
44 }
45}
46
47impl Error for Jeeperr {}
48
49#[cfg(feature = "gpu_accel")]
50impl From<ClError> for Jeeperr {
51 fn from(err: ClError) -> Self {
52 Jeeperr::ClError(err)
53 }
54}