Sha256: 912b74372b612eb3cf7dc3c4ce8bfea4dd024b185b2467f33c8d5e11bb1345b9
Contents?: true
Size: 805 Bytes
Versions: 44
Compression:
Stored size: 805 Bytes
Contents
module Deas class ErrorHandler def self.run(*args) self.new(*args).run end def initialize(exception, sinatra_call, error_procs) @exception = exception @sinatra_call = sinatra_call @error_procs = [*error_procs].compact end def run response = nil @error_procs.each do |error_proc| begin result = @sinatra_call.instance_exec(@exception, &error_proc) response = result if result rescue Exception => proc_exception @exception = proc_exception # reset the response if an exception occurs while evaulating the # error procs -- a new exception will now be handled by the # remaining procs response = nil end end response end end end
Version data entries
44 entries across 44 versions & 1 rubygems