Links
exception_handler
Categories
exception_handler
Allows you to register handlers for exceptions in your controllers like:
class ApplicationController < ActionController::Base
class NotAuthorized < RuntimeError;end
register_exception NotAuthorized, :not_authorized
private
def not_authorized
flash[ :error ] = 'You are not authorized to perform the requested ' +
'action.'
render :text => '', :layout => true, :status => 401
end
end
In this example, you could raise an ApplicationController::NotAuthorized exception anywhere in the course of processing an action, and instead of just getting an error report or a 500 error in the browser, the user would see the page with your error message and the browser gets a 401 status code.
Vitals
| Home | http://johnwilger.com/pages/exception_handler |
|---|---|
| Repository | svn://source.johnwilger.com/plugins/exception_handler |
| License | PublicDomain |
| Rating | (2 votes) |
| Owner | John Wilger |
| Created | 27 April 2006 |
Comments
-
This svn repository does not seem to be up anymore.
