Module: Hobbit::ErrorHandling

Defined in:
lib/hobbit/error_handling.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(othermod) ⇒ Object



23
24
25
# File 'lib/hobbit/error_handling.rb', line 23

def self.included(othermod)
  othermod.extend ClassMethods
end

Instance Method Details

#_call(env) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/hobbit/error_handling.rb', line 13

def _call(env)
  super
rescue *self.class.errors.keys => e
  rescued = self.class.errors.keys.detect { |k| e.kind_of?(k) }

  env['hobbit.error'] = e
  response.write instance_eval(&self.class.errors[rescued])
  response.finish
end