Class: Rack::App::ErrorHandler
- Inherits:
-
Object
- Object
- Rack::App::ErrorHandler
- Defined in:
- lib/rack/app/error_handler.rb
Instance Attribute Summary collapse
-
#handlers ⇒ Object
readonly
Returns the value of attribute handlers.
Instance Method Summary collapse
- #execute_with_error_handling_for(instance) ⇒ Object
-
#initialize ⇒ ErrorHandler
constructor
A new instance of ErrorHandler.
- #register_handler(exception_classes, handler_block) ⇒ Object
Constructor Details
#initialize ⇒ ErrorHandler
Returns a new instance of ErrorHandler.
5 6 7 |
# File 'lib/rack/app/error_handler.rb', line 5 def initialize @handlers = {} end |
Instance Attribute Details
#handlers ⇒ Object (readonly)
Returns the value of attribute handlers.
3 4 5 |
# File 'lib/rack/app/error_handler.rb', line 3 def handlers @handlers end |
Instance Method Details
#execute_with_error_handling_for(instance) ⇒ Object
16 17 18 19 20 |
# 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) ⇒ Object
9 10 11 12 13 14 |
# 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 |