module Roda::RodaPlugins::ErrorHandler::InstanceMethods
Public Instance Methods
Source
# File lib/roda/plugins/error_handler.rb, line 86 def _roda_handle_main_route begin res = super ensure _roda_after(res) end rescue *opts[:error_handler_classes] => e _handle_error(e) end
If an error occurs, set the response status to 500 and call the error handler.
Calls superclass method
Source
# File lib/roda/plugins/error_handler.rb, line 73 def call # RODA4: Remove begin res = super ensure _roda_after(res) end rescue *opts[:error_handler_classes] => e _handle_error(e) end
If an error occurs, set the response status to 500 and call the error handler. Old Dispatch API.
Calls superclass method
Private Instance Methods
Source
# File lib/roda/plugins/error_handler.rb, line 106 def _handle_error(e) res = @_response res.send(:initialize) res.status = 500 res = _roda_handle_route{handle_error(e)} begin _roda_after(res) rescue => e2 if errors = env['rack.errors'] errors.puts "Error in after hook processing of error handler: #{e2.class}: #{e2.message}" e2.backtrace.each{|line| errors.puts(line)} end end res end
Handle the given exception using handle_error
, using a default status of 500. Run after hooks on the rack response, but if any error occurs when doing so, log the error using rack.errors and return the response.
Source
# File lib/roda/plugins/error_handler.rb, line 100 def _roda_after(res) end
Default empty implementation of _roda_after
, usually overridden by Roda.def_roda_before.
Source
# File lib/roda/plugins/error_handler.rb, line 125 def handle_error(e) raise e end
By default, have the error handler reraise the error, so using the plugin without installing an error handler doesn’t change behavior.