@@ -44,7 +44,8 @@ struct HTTPAPIResponse {
44
44
45
45
#[ derive( serde:: Serialize ) ]
46
46
struct HTTPAPIErrorResponse {
47
- error_code : i32 ,
47
+ // TODO: should have an error type to help distungish between curl native errors and custom app logic errors
48
+ error_code : Option < i32 > ,
48
49
error_message : String ,
49
50
}
50
51
@@ -66,7 +67,7 @@ fn http_request(
66
67
// println!("{}, {}", url, url_encode);
67
68
68
69
let mut error_str: String = "" . to_string ( ) ;
69
- let mut error_code: i32 = - 1 ;
70
+ let mut error_code: Option < i32 > = None ;
70
71
71
72
match easy. url (
72
73
// Setting - OFF
@@ -79,7 +80,7 @@ fn http_request(
79
80
Err ( e) => {
80
81
return Err ( HTTPAPIErrorResponse {
81
82
error_code : error_code,
82
- error_message : format ! ( "Test - {}" , e. to_string( ) ) ,
83
+ error_message : format ! ( "{}" , e. to_string( ) ) ,
83
84
} )
84
85
}
85
86
}
@@ -228,7 +229,7 @@ fn http_request(
228
229
Err ( e) => {
229
230
return Err ( HTTPAPIErrorResponse {
230
231
error_code : error_code,
231
- error_message : format ! ( "Test - {}" , e. to_string( ) ) ,
232
+ error_message : format ! ( "{}" , e. to_string( ) ) ,
232
233
} )
233
234
}
234
235
} ;
@@ -349,7 +350,7 @@ fn http_request(
349
350
println ! ( "Request failed: {}" , err) ;
350
351
351
352
return Err ( HTTPAPIErrorResponse {
352
- error_code : err. code ( ) ,
353
+ error_code : Some ( err. code ( ) ) ,
353
354
error_message : err. to_string ( ) ,
354
355
} ) ;
355
356
}
0 commit comments