ozzo-routing icon indicating copy to clipboard operation
ozzo-routing copied to clipboard

HTTPError with StatusBadRequest return a response with 500 Internal Error

Open asaintgenis opened this issue 7 years ago • 1 comments

Hello,

In the API layer of my app, Every call can return HTTPError with various Status.

For exemple in case of a no found objet for a GET call I return : return routing.NewHTTPError(http.StatusNotFound, err.Error()) The response head will be correctly set.

But when I use the http.StatusBadRequest in the exact same way (for example a POST with invalid validation):

return routing.NewHTTPError(http.StatusBadRequest)

The response header is set to 500 Internal Server Error instead of 400 Bad request.

Thanks, Regards, Arthur

asaintgenis avatar Sep 18 '17 18:09 asaintgenis

I'm actually getting 500 Internal Server Error for every routing.NewHTTPError I return. Did you figure out what was causing this?

aaronn avatar Apr 04 '19 03:04 aaronn