module Mojito::Helpers::ExceptionHandling

Public Class Methods

included(type) click to toggle source
# File lib/mojito/helpers/exception_handling.rb, line 24
def self.included(type)
        type.extend ClassMethods
end

Public Instance Methods

__handle_error(exception) click to toggle source
# File lib/mojito/helpers/exception_handling.rb, line 40
def __handle_error(exception)
        if handler = case exception
                when MojitoException
                        response.status = exception.status
                        self.class.error_handlers[exception.status]
                when Exception
                        self.class.error_handlers[exception.class]
                end
                instance_exec &handler
        end
        raise exception
end
raise(exception) click to toggle source
# File lib/mojito/helpers/exception_handling.rb, line 28
def raise(exception)
        backtrace = caller[1..-1]
        Kernel.raise case exception
        when Symbol, Integer
                Mojito::MojitoException.new(exception)
        when Exception
                exception
        else
                RuntimeError.new(exception)
        end.tap {|e| e.set_backtrace backtrace }
end