Skip to content

Commit

Permalink
Implement more meaningful 5xx error responses (Issue #445) (#451)
Browse files Browse the repository at this point in the history
* Issue #445 and OneDrive/onedrive-api-docs#1035 highlight that the current 5xx error messages are too generic and need to be more specific. This patch makes those error messages more specific to the response code from OneDrive API
  • Loading branch information
abraunegg authored Apr 4, 2019
1 parent f93ed00 commit 7c2b3e8
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions src/onedrive.d
Original file line number Diff line number Diff line change
Expand Up @@ -711,10 +711,25 @@ final class OneDriveApi
// 502 - Bad Gateway
// 503 - Service Unavailable
// 504 - Gateway Timeout (Issue #320)
case 500,502,503,504:
case 500:
// No actions
log.vlog("OneDrive returned a 'HTTP 5xx Server Side Error' - gracefully handling error");
break;
log.vlog("OneDrive returned a 'HTTP 500 Internal Server Error' - gracefully handling error");
break;

case 502:
// No actions
log.vlog("OneDrive returned a 'HTTP 502 Bad Gateway Error' - gracefully handling error");
break;

case 503:
// No actions
log.vlog("OneDrive returned a 'HTTP 503 Service Unavailable Error' - gracefully handling error");
break;

case 504:
// No actions
log.vlog("OneDrive returned a 'HTTP 504 Gateway Timeout Error' - gracefully handling error");
break;

// "else"
default:
Expand Down Expand Up @@ -742,9 +757,24 @@ final class OneDriveApi
// 502 - Bad Gateway
// 503 - Service Unavailable
// 504 - Gateway Timeout (Issue #320)
case 500,502,503,504:
case 500:
// No actions
log.vlog("OneDrive returned a 'HTTP 500 Internal Server Error' - gracefully handling error");
break;

case 502:
// No actions
log.vlog("OneDrive returned a 'HTTP 502 Bad Gateway Error' - gracefully handling error");
break;

case 503:
// No actions
log.vlog("OneDrive returned a 'HTTP 503 Service Unavailable Error' - gracefully handling error");
break;

case 504:
// No actions
log.vlog("OneDrive returned a 'HTTP 5xx Server Side Error' - gracefully handling error");
log.vlog("OneDrive returned a 'HTTP 504 Gateway Timeout Error' - gracefully handling error");
break;

// Default - all other errors that are not a 2xx or a 302
Expand Down

0 comments on commit 7c2b3e8

Please sign in to comment.