module M
class AuthenticationSystemError < StandardError
end
class NotAuthorizedError < AuthenticationSystemError
end
def self.included(base)
base.class_eval do
rescue_from M::NotAuthorizedError, :with => :not_authorized
end
end
def not_authorized(exception)
render :text => 'handler was called'
end
end
class ApplicationController < ActionController::Base
include M
end
class TesterController < ApplicationController
def index
raise M::NotAuthorizedError
end
end