IQSS/10812 - Add details to error messages #10813
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it: This PR incorporates any messages added to a BadRequestException when it is thrown into the final message the API user sees. If there is no message, the error response is generic as before.
Which issue(s) this PR closes:
Closes #10812
Special notes for your reviewer: Feel free to improve the message
Suggestions on how to test this: Make a call such as
curl -H 'X-Dataverse-key:e6affd89-03f5-4b61-8ed6-d9af41228df2' -X PUT -d '{"https://dataverse.org/schema/core#fileTermsOfAccess":{"https://dataverse.org/schema/core#dataAccessPlace":"OTR"}}' -H "Content-type:application/ld+json" -H "Accept:application/ld+json" http://localhost:8080/api/datasets/10345/metadata
twice on a dataset (once to add the value, and the second time to trigger an error ("Can't append to a single-value field that already has a value: https://dataverse.org/schema/core#dataAccessPlace") - and verify that the test above is part of the API 400 response you get. (FWIW: If you want the call to succeed, add ?replace=true to the call).Does this PR introduce a user interface change? If mockups are available, please link/include them here:
Is there a release notes update needed for this change?: - It's a change to the "message" included in the error responses for some API calls (and we already have messages that change due to i18n), so I don't think it's needed, but I'd be happy to have a "Error messages for some API calls have more detail" as a release note and/or to have it mentioned in a change log.
Additional documentation: