-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Description
I'm curious if this was discussed before and done intentionally.
For some reason, the status
value is not passed into the format_message
method here in error!
:
grape/lib/grape/middleware/error.rb
Lines 132 to 137 in 5ce44de
def error!(message, status = options[:default_status], headers = {}, backtrace = [], original_exception = nil) | |
rack_response( | |
status, headers.reverse_merge(Rack::CONTENT_TYPE => content_type), | |
format_message(message, backtrace, original_exception) | |
) | |
end |
Passing it would make including it in the response body JSON easier. This is the way it's included in the JSON API error response bodies:
# HTTP/1.1 422 Unprocessable Entity
# Content-Type: application/vnd.api+json
{
"errors": [
{
"status": "422",
"source": { "pointer": "/data/attributes/firstName" },
"title": "Invalid Attribute",
"detail": "First name must contain at least two characters."
}
]
}