Repository navigation
Rescue Http errors with given message - #844
Conversation
|
Thanks dear review, There is already the In this PR, we add a default behavior (outside 400, 401, 404 and 422 explicit error codes), Else, fallback to current behavior. I pushed this in 2nd commit, WDYT? |
bb739b1 to
c626a30
Compare
|
Thanks for the ✅ , I'll squash commits and fix the conflict before merging it |
This is a long term missing feature in the CLI
(noticed while implementing paywall and error :payment_required
on Bump.sh API).
With this commit, when http error code has a message and not explicitly catched
(400, 401, 404, 422),
we display the provided error message to the CLI user, with the status.
There is already the `info.length > 0` validation,
and generic message is raised when info is nil:
`Unhandled API error (status: ${status}) (error: ${httpError})`
Else, fallback to current behavior:
> `Unhandled API error (status: ${status}) (error: ${httpError})`
c626a30 to
59bf8cb
Compare
| static genericErrorFromMessage(error: Error): MessagesAndExitCode { | ||
| return error.message ? [[error.message], 100] : [[], 100] | ||
| } |
There was a problem hiding this comment.
I would have kept the http status to have the same logic as the other errors :)
| static genericErrorFromMessage(error: Error): MessagesAndExitCode { | |
| return error.message ? [[error.message], 100] : [[], 100] | |
| } | |
| static genericErrorFromMessage(error: Error, status: number): MessagesAndExitCode { | |
| return [error.message ? [error.message] : [], status - 300] | |
| } |
4xx only, read http error message
This is a long term missing feature in the CLI
(noticed while implementing paywall and error
payment_requiredwith status 402 on Bump.sh API).With this commit, when http error code is 4xx and not explicitly catched (400, 401, 404, 422),
we return the provided error message to the CLI user, with the status.