|
| 1 | +use std::error::Error; |
| 2 | +use std::fmt::{Display, Formatter}; |
| 3 | +use std::fmt::Error as FmtError; |
| 4 | + |
1 | 5 | #[repr(C)] |
2 | 6 | #[derive(Clone, Copy, Debug)] |
3 | 7 | pub enum AfError { |
@@ -74,6 +78,35 @@ pub enum AfError { |
74 | 78 | ERR_UNKNOWN = 999 |
75 | 79 | } |
76 | 80 |
|
| 81 | +impl Display for AfError { |
| 82 | + fn fmt(&self, f: &mut Formatter) -> Result<(), FmtError> { |
| 83 | + write!(f, "{}", self.description()) |
| 84 | + } |
| 85 | +} |
| 86 | + |
| 87 | +impl Error for AfError { |
| 88 | + fn description(&self) -> &str { |
| 89 | + match *self { |
| 90 | + AfError::SUCCESS => "Function returned successfully", |
| 91 | + AfError::ERR_NO_MEM => "The system or device ran out of memory", |
| 92 | + AfError::ERR_DRIVER => "Device driver error", |
| 93 | + AfError::ERR_RUNTIME => "Error in runtime environment", |
| 94 | + AfError::ERR_INVALID_ARRAY => "Input is not a valid Array Object", |
| 95 | + AfError::ERR_ARG => "One of the function arguments is incorrect", |
| 96 | + AfError::ERR_SIZE => "The size is incorrect", |
| 97 | + AfError::ERR_TYPE => "The type is not supported by this function", |
| 98 | + AfError::ERR_DIFF_TYPE => "The type of input arrays are not compatible", |
| 99 | + AfError::ERR_BATCH => "Function does not support GFOR / batch mode", |
| 100 | + AfError::ERR_NOT_SUPPORTED => "The option is not supported", |
| 101 | + AfError::ERR_NOT_CONFIGURED => "This build of ArrayFire does not support this feature", |
| 102 | + AfError::ERR_NO_DBL => "This device does not support double", |
| 103 | + AfError::ERR_NO_GFX => "This build of ArrayFire was not built with graphics or this device does not support graphics", |
| 104 | + AfError::ERR_INTERNAL => "There was an internal error in either ArrayFire or upstream project", |
| 105 | + AfError::ERR_UNKNOWN => "Unkown Error", |
| 106 | + } |
| 107 | + } |
| 108 | +} |
| 109 | + |
77 | 110 | #[derive(Copy, Clone)] |
78 | 111 | pub enum Aftype { |
79 | 112 | F32 = 0, |
|
0 commit comments