Open wmertens opened 9 years ago
+1.
I haven't seen any code regarding error handling. What happens when the promise fails?
+1
I also wonders what happens when promises fail?
what happens when promises fail?
next
is used as a callback, so the first promise to reject gets its error there. This error gets handled by express as usual (sending error message to user with a 500 status).
This is sometimes a security problem, but it's a general express feature, not unique to this package.
However, if you just do Promise.reject() somewhere then err
will be undefined
. This would make other middleware think everything is fine and empty response with code 200 would be sent to the user.
As for OP, now you can use https://github.com/jshttp/http-errors
Would be nice if express-promise provided an HttpError object that can be thrown from promises to result in a certain HTTP error.