class Deas::ErrorHandler
Attributes
context[R]
error_procs[R]
exception[R]
Public Class Methods
new(exception, context_hash)
click to toggle source
# File lib/deas/error_handler.rb, line 11 def initialize(exception, context_hash) @exception = exception @context = Context.new(context_hash) @error_procs = context_hash[:server_data].error_procs.reverse end
run(*args)
click to toggle source
# File lib/deas/error_handler.rb, line 5 def self.run(*args) self.new(*args).run end
Public Instance Methods
run()
click to toggle source
The exception that we are generating a response for can change in the case that the configured error proc raises an exception. If this occurs, a response will be generated for that exception, instead of the original one. This is designed to avoid “hidden” errors happening, this way the server will respond and log based on the last exception that occurred.
# File lib/deas/error_handler.rb, line 23 def run @error_procs.inject(nil) do |response, error_proc| result = begin error_proc.call(@exception, @context) rescue StandardError => proc_exception @exception = proc_exception response = nil # reset response end response || result end end