Open NivGreenstein opened 2 months ago
@netanelC @shimoncohen are you aware of this bug ?
@NivGreenstein please use reject, resolve and next correctly. You should
return reject(new BadRequestError("message"));
same for resolve and next
@netanelC @shimoncohen are you aware of this bug ?
I wasn't aware, thanks
Describe the bug I've created custom Errors that implement
HttpError
interface from@map-colonies/error-express-handler
. For non-async routes, when error is being thrown, the middleware catches it and sends the right error and http code. For async routes, when the same error is thrown, the server crash. In order to solve this issue, I had to add Try-Catch for every async route. With this patch, I once again got the server to respond with the expected output (expected http code and message).To Reproduce Steps to reproduce the behavior:
getErrorHandlerMiddleware()
from@map-colonies/error-express-handler
as post routes middleware. Example:app.use(getErrorHandlerMiddleware());
Expected behavior I'd expect that the middleware will catch errors thrown at both async and non-async routes.
Screenshots The custom error implementation:
Non-async route:
Postman response (as expected):
Async route that throws the same error:
Error:
Try-catch implementation: