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
Let's add the ability to specify exceptions to rescue from in handlers by defining a new macro similar to Rails' rescue_from.
Rationale
Presently, the framework does not allow to easily declare exceptions to rescue from in handlers. The only way to do that is to implement some custom rescue logic in the #dispatch or HTTP method-specific method (such as #get or #post for example).
Proposition
Let's add a new #rescue_from macro to handlers that will allow defining specific exceptions that need to be rescued as well as the name of a method that must be executed when these exceptions are indeed rescued:
classProfileHandler < Marten::Handlers::TemplateincludeRequireSignedInUser
rescue_from Auth::UnauthorizedUser, with::handle_unauthorized_user
template_name "auth/profile.html"privatedefhandle_unauthorized_user
head :forbiddenendend
If the specific callback returns a valid HTTP response, then it should be used as is and returned by the handler. Obviously the callback could also raise a different kind of error, but if the handler returns a value that is not an HTTP response then the original exceptions should be re-raised.
The text was updated successfully, but these errors were encountered:
Description
Let's add the ability to specify exceptions to rescue from in handlers by defining a new macro similar to Rails'
rescue_from
.Rationale
Presently, the framework does not allow to easily declare exceptions to rescue from in handlers. The only way to do that is to implement some custom rescue logic in the
#dispatch
or HTTP method-specific method (such as#get
or#post
for example).Proposition
Let's add a new
#rescue_from
macro to handlers that will allow defining specific exceptions that need to be rescued as well as the name of a method that must be executed when these exceptions are indeed rescued:If the specific callback returns a valid HTTP response, then it should be used as is and returned by the handler. Obviously the callback could also raise a different kind of error, but if the handler returns a value that is not an HTTP response then the original exceptions should be re-raised.
The text was updated successfully, but these errors were encountered: