You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be desirable to be able to provide generic error messages instead of the exception message after a resource method raises a StandardError.
Proposed solution
We can include ActiveSupport::Rescuable in Restfulness::Resource (active_support is already a dependency of restfulness) to allow resources to declare custom error handlers via rescue_from.
Something like:
classApplicationResource < Restfulness::Resourcerescue_fromStandardErrordoself.status,self.payload=[500,{message: 'Internal Server Error'}]endend
And then, in the Restfulness::Response object ask if the resource has error handlers for that type of error before rendering the default error message (e.message).
Any thoughts?
The text was updated successfully, but these errors were encountered:
nicolasgarnil
changed the title
Provide generic error messages instead of exception messages
Cannot provide custom error messages 500 error messages
Mar 2, 2017
nicolasgarnil
changed the title
Cannot provide custom error messages 500 error messages
Cannot provide custom 500 error messages
Mar 7, 2017
Problem
It would be desirable to be able to provide generic error messages instead of the exception message after a resource method raises a
StandardError
.Proposed solution
We can include ActiveSupport::Rescuable in
Restfulness::Resource
(active_support
is already a dependency ofrestfulness
) to allow resources to declare custom error handlers viarescue_from
.Something like:
And then, in the
Restfulness::Response
object ask if the resource has error handlers for that type of error before rendering the default error message (e.message
).Any thoughts?
The text was updated successfully, but these errors were encountered: