-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(auth): return objects during GNAP errors #2779
Conversation
✅ Deploy Preview for brilliant-pasca-3e80ec canceled.
|
@@ -57,10 +57,19 @@ export async function gnapServerErrorMiddleware( | |||
'Received error when handling Open Payments GNAP request' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
main changes here: don't throw error, but return status & body. Follows error handling koa docs: https://github.com/koajs/koa/blob/master/docs/error-handling.md
ctx.body = { | ||
error: { description: err.message } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not a GNAP error per se, just a validation error, for which we just add the description
ctx.body = { | ||
error: { description: err.message } | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not a GNAP error per se, just a validation error, for which we just add the description
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Changes proposed in this pull request
Updates how errors are displayed when making requests to the AS, to be more in-line with the spec. This improves error handling in general as it allows for parsing error codes, and making use of the description.
Before:
After:
This PR also adds some if-checks to the OP post requests scripts in bruno, in order not to prevent any errors from being hidden, since when post requests scripts would fail to parse response body information, the script error would override the actual response error.
Context
General OP error handling #1905
Checklist
fixes #number