@@ -15,13 +15,15 @@ pub enum WpApiError {
15
15
#[ error( "Status code ({}) is not valid" , status_code) ]
16
16
InvalidHttpStatusCode { status_code : u16 } ,
17
17
#[ error(
18
- "Request execution failed!\n Status Code: '{:?}'. \n Response : '{}'" ,
18
+ "Request execution failed!\n Status Code: '{:?}'\n Redirects : '{:#?}' \n Reason: '{:#? }'" ,
19
19
status_code,
20
+ redirects,
20
21
reason
21
22
) ]
22
23
RequestExecutionFailed {
23
24
status_code : Option < u16 > ,
24
- reason : String ,
25
+ redirects : Option < Vec < String > > ,
26
+ reason : RequestExecutionErrorReason ,
25
27
} ,
26
28
#[ error( "Media file not found at file path: {}" , file_path) ]
27
29
MediaFileNotFound { file_path : String } ,
@@ -419,26 +421,42 @@ pub enum WpErrorCode {
419
421
#[ derive( Debug , Clone , PartialEq , Eq , thiserror:: Error , uniffi:: Error ) ]
420
422
pub enum RequestExecutionError {
421
423
#[ error(
422
- "Request execution failed!\n Status Code: '{:?}'. \n Response : '{}'" ,
424
+ "Request execution failed!\n Status Code: '{:?}'\n Redirects : '{:#?}' \n Reason: '{:#? }'" ,
423
425
status_code,
426
+ redirects,
424
427
reason
425
428
) ]
426
429
RequestExecutionFailed {
427
430
status_code : Option < u16 > ,
428
- reason : String ,
431
+ redirects : Option < Vec < String > > ,
432
+ reason : RequestExecutionErrorReason ,
433
+ } ,
434
+ }
435
+
436
+ #[ derive( Debug , Clone , PartialEq , Eq , uniffi:: Enum ) ]
437
+ pub enum RequestExecutionErrorReason {
438
+ SslError {
439
+ domain : String ,
440
+ trust_chain : Option < Vec < String > > ,
441
+ error_message : String ,
442
+ } ,
443
+ GenericError {
444
+ error_message : String ,
429
445
} ,
430
446
}
431
447
432
448
#[ derive( Debug , Clone , PartialEq , Eq , thiserror:: Error , uniffi:: Error ) ]
433
449
pub enum MediaUploadRequestExecutionError {
434
450
#[ error(
435
- "Request execution failed!\n Status Code: '{:?}'. \n Response : '{}'" ,
451
+ "Request execution failed!\n Status Code: '{:?}'\n Redirects : '{:#?}' \n Reason: '{:#? }'" ,
436
452
status_code,
453
+ redirects,
437
454
reason
438
455
) ]
439
456
RequestExecutionFailed {
440
457
status_code : Option < u16 > ,
441
- reason : String ,
458
+ redirects : Option < Vec < String > > ,
459
+ reason : RequestExecutionErrorReason ,
442
460
} ,
443
461
#[ error( "Media file not found at file path: {}" , file_path) ]
444
462
MediaFileNotFound { file_path : String } ,
@@ -449,9 +467,11 @@ impl From<RequestExecutionError> for WpApiError {
449
467
match value {
450
468
RequestExecutionError :: RequestExecutionFailed {
451
469
status_code,
470
+ redirects,
452
471
reason,
453
472
} => Self :: RequestExecutionFailed {
454
473
status_code,
474
+ redirects,
455
475
reason,
456
476
} ,
457
477
}
@@ -463,9 +483,11 @@ impl From<MediaUploadRequestExecutionError> for WpApiError {
463
483
match value {
464
484
MediaUploadRequestExecutionError :: RequestExecutionFailed {
465
485
status_code,
486
+ redirects,
466
487
reason,
467
488
} => Self :: RequestExecutionFailed {
468
489
status_code,
490
+ redirects,
469
491
reason,
470
492
} ,
471
493
MediaUploadRequestExecutionError :: MediaFileNotFound { file_path } => {
0 commit comments