Class: RestCore::ErrorHandler

Inherits:
Object
  • Object
show all
Includes:
Middleware
Defined in:
lib/rest-core/middleware/error_handler.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.membersObject



4
# File 'lib/rest-core/middleware/error_handler.rb', line 4

def self.members; [:error_handler]; end

Instance Method Details

#call(env) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/rest-core/middleware/error_handler.rb', line 7

def call env
  app.call(env){ |res|
    h = error_handler(res)
    f = res[FAIL] || []
    yield(if f.empty? || f.find{ |ff| ff.kind_of?(Exception) } || !h
            res
          else
            fail(res, h.call(res))
          end)}
end