Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: remove uses of type errors from user-facing code (#3553)
BREAKING CHANGE: This changes the `name` property of a small number of error responses that we return. The property would have been `TypeError`, but is now `ValidationError` instead. It's a grey area, but I'd rather be strict. --- This change removes uses of the `TypeError` type from user-facing code. Type errors are used by typescript when you provide it the wrong type. This is a valid concern. However, in the API, they're usually a signal that **we've** done something wrong rather than the user having done something wrong. As such, it makes more sense to return them as validation errors or bad request errors. ## Breaking changes Note that because of the way we handle errors, some of these changes will be made visible to the end user, but only in the response body. ```ts { "name": "TypeError", "message": "Something is wrong", "isJoi": true } ``` will become ```ts { "name": "ValidationError", "message": "Something is wrong", "isJoi": true } ``` Technically, this could be considered a breaking change. However, as we're gearing up for v5, this might be a good time to merge that? ## A return to 500 This PR also makes TypeErrors a 500-type error again because they should never be caused by invalid data provided by the user
- Loading branch information
1 parent
e11fae5
commit 34204c3
Showing
4 changed files
with
36 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters