Closed nortron closed 11 months ago
Looks good to me, good idea with a centralized error handler. 👍 One thing though - can you pls change notFoundResponse to be just Not Found instead of Endpoint does not exist.
@MateuszKikmunter No problem, updated to "Not found" with a lowercase "found" to be consistent with the "Something went wrong" capitalization. Happy to make it all caps if you'd prefer that.
@MateuszKikmunter No problem, updated to "Not found" with a lowercase "found" to be consistent with the "Something went wrong" capitalization. Happy to make it all caps if you'd prefer that.
Thanks, looks good to me, now it needs to be approved by @gitfrosh :)
These 3 commits attempt to make the API more consistent in returning JSON errors with non-2xx HTTP error codes.
Starting with Express 5, route handlers and middleware that return a Promise will call next(value) automatically when they reject or throw an error
. If this repo is ever ever upgraded to Express 5 (currently on 4.17) or later these new try blocks can be entirely removed, the next() calls will be automatic.The 4th commit updates a code comment to reflect the latest code.