class Rack::App::ErrorHandler
Attributes
handlers[R]
Public Class Methods
new()
click to toggle source
# File lib/rack/app/error_handler.rb, line 5 def initialize @handlers = {} end
Public Instance Methods
execute_with_error_handling_for(instance) { || ... }
click to toggle source
# File lib/rack/app/error_handler.rb, line 16 def execute_with_error_handling_for(instance) yield rescue *[Exception, @handlers.keys].flatten => ex instance.instance_exec(ex, &get_handler(ex)) end
register_handler(exception_classes, handler_block)
click to toggle source
# File lib/rack/app/error_handler.rb, line 9 def register_handler(exception_classes, handler_block) exception_classes.each do |exception_class| @handlers[exception_class]= handler_block end nil end
Protected Instance Methods
explicit(ex)
click to toggle source
# File lib/rack/app/error_handler.rb, line 28 def explicit(ex) @handlers[ex.class] end
get_handler(ex)
click to toggle source
# File lib/rack/app/error_handler.rb, line 24 def get_handler(ex) explicit(ex) || parent(ex) || raise(ex) end
parent(ex)
click to toggle source
# File lib/rack/app/error_handler.rb, line 32 def parent(ex) handler = @handlers.find { |exception_class, _| ex.class <= exception_class } return handler.nil? ? nil : handler.last end