@@ -44,7 +44,8 @@ struct HTTPAPIResponse {
4444
4545#[ derive( serde:: Serialize ) ]
4646struct 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 < u32 > ,
4849 error_message : String ,
4950}
5051
@@ -66,7 +67,7 @@ fn http_request(
6667 // println!("{}, {}", url, url_encode);
6768
6869 let mut error_str: String = "" . to_string ( ) ;
69- let mut error_code: i32 = - 1 ;
70+ let mut error_code: Option < u32 > = None ;
7071
7172 match easy. url (
7273 // Setting - OFF
@@ -79,7 +80,7 @@ fn http_request(
7980 Err ( e) => {
8081 return Err ( HTTPAPIErrorResponse {
8182 error_code : error_code,
82- error_message : format ! ( "Test - {}" , e. to_string( ) ) ,
83+ error_message : format ! ( "{}" , e. to_string( ) ) ,
8384 } )
8485 }
8586 }
@@ -228,7 +229,7 @@ fn http_request(
228229 Err ( e) => {
229230 return Err ( HTTPAPIErrorResponse {
230231 error_code : error_code,
231- error_message : format ! ( "Test - {}" , e. to_string( ) ) ,
232+ error_message : format ! ( "{}" , e. to_string( ) ) ,
232233 } )
233234 }
234235 } ;
@@ -349,7 +350,7 @@ fn http_request(
349350 println ! ( "Request failed: {}" , err) ;
350351
351352 return Err ( HTTPAPIErrorResponse {
352- error_code : err. code ( ) ,
353+ error_code : Some ( err. code ( ) . try_into ( ) . unwrap ( ) ) ,
353354 error_message : err. to_string ( ) ,
354355 } ) ;
355356 }
0 commit comments