-
Notifications
You must be signed in to change notification settings - Fork 3
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
Improve error handling. #172
Conversation
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.
Approving provided Author feels this is ready.
@davidlehn this might be something for a subsequent PR, but according to the VC-API this should be returning the verification results in the body of the response. Not sure if this PR is doing that. |
I was hoping for a bit more discussion here. This does handle one specific jsonld.js error code. But it doesn't handle any others, or any of the generic vc errors, so the first simple tests I wrote still fail. I'm not sure where the line is on exposing more details with |
I think we can add better error support incrementally -- just having what you have here is really useful so we should not wait on it. |
- Return 400 instead of 500 for some common errors.
Co-authored-by: Dave Longley <[email protected]>
- Don't wrap BedrockErrors. - Special case error names that shouold be 'DataError'. - Add more complex stack trace stripping. - Update tests.
eb53408
to
a667db8
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #172 +/- ##
==========================================
+ Coverage 90.53% 90.72% +0.19%
==========================================
Files 17 17
Lines 3170 3235 +65
==========================================
+ Hits 2870 2935 +65
Misses 300 300
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
This code got a bit tricky. There are a variety of errors that could be thrown, and it's unclear how dependent other code might be on what this API returns. This is trying to improve it a bit. The |
throw error; | ||
} | ||
|
||
function _stripStackTrace(error) { |
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 implementation needs to be updated (it was taken from a source where some bugs were discovered):
https://github.com/digitalbazaar/bedrock-vc-delivery/blob/main/lib/helpers.js#L151-L170
Once that's updated, I think this is ready to go.
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.
Aligned more with that code. jsonld.js doc loader is using .details.cause
for not found errors, which also need stripping. Not sure if that's an issue in the other library as well.
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.
I think it's probably fine.
- Use `serialize-error` and allow list of error keys when create error. - More alignment with bedrock-vc-delivery error code.
Addresses: #169.