File tree Expand file tree Collapse file tree 3 files changed +6
-13
lines changed Expand file tree Collapse file tree 3 files changed +6
-13
lines changed Original file line number Diff line number Diff line change 1
1
extern crate num;
2
2
3
3
use self :: num:: Complex ;
4
- use std:: error:: Error ;
5
4
use std:: fmt:: Error as FmtError ;
6
5
use std:: fmt:: { Display , Formatter } ;
7
6
@@ -80,13 +79,7 @@ impl Display for Backend {
80
79
81
80
impl Display for AfError {
82
81
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 {
82
+ let text = match * self {
90
83
AfError :: SUCCESS => "Function returned successfully" ,
91
84
AfError :: ERR_NO_MEM => "System or Device ran out of memory" ,
92
85
AfError :: ERR_DRIVER => "Error in the device driver" ,
@@ -104,7 +97,8 @@ impl Error for AfError {
104
97
AfError :: ERR_NO_GFX => "This build of ArrayFire has no graphics support" ,
105
98
AfError :: ERR_INTERNAL => "Error either in ArrayFire or in a project upstream" ,
106
99
AfError :: ERR_UNKNOWN => "Unknown Error" ,
107
- }
100
+ } ;
101
+ write ! ( f, "{}" , text)
108
102
}
109
103
}
110
104
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ extern crate libc;
3
3
use self :: libc:: c_char;
4
4
use crate :: defines:: AfError ;
5
5
use crate :: util:: { free_host, DimT , MutDimT } ;
6
- use std:: error:: Error ;
7
6
use std:: ffi:: CStr ;
8
7
use std:: ops:: { Deref , DerefMut } ;
9
8
use std:: sync:: RwLock ;
@@ -39,7 +38,7 @@ pub fn handle_error_general(error_code: AfError) {
39
38
AfError :: SUCCESS => { } /* No-op */
40
39
_ => panic ! (
41
40
"Error message: {}\n Last error: {}" ,
42
- error_code. description ( ) ,
41
+ error_code,
43
42
get_last_error( )
44
43
) ,
45
44
}
@@ -63,7 +62,7 @@ lazy_static! {
63
62
/// fn handle_error(error_code: AfError) {
64
63
/// match error_code {
65
64
/// AfError::SUCCESS => {}, /* No-op */
66
- /// _ => panic!("Error message: {}", error_code.description() ),
65
+ /// _ => panic!("Error message: {}", error_code),
67
66
/// }
68
67
/// }
69
68
///
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ macro_rules! implement_handler {
8
8
pub fn $fn_name( error_code: AfError ) {
9
9
match error_code {
10
10
AfError :: SUCCESS => { } /* No-op */
11
- _ => panic!( "Error message: {}" , error_code. description ( ) ) ,
11
+ _ => panic!( "Error message: {}" , error_code) ,
12
12
}
13
13
}
14
14
} ;
You can’t perform that action at this time.
0 commit comments