Class: Rester::Service::Middleware::ErrorHandling

Inherits:
Base
  • Object
show all
Defined in:
lib/rester/service/middleware/error_handling.rb

Overview

Provides error handling for Rester. Should be mounted above all other Rester middleware.

Instance Attribute Summary

Attributes inherited from Base

#app, #options

Instance Method Summary collapse

Methods inherited from Base

#initialize, #service

Constructor Details

This class inherits a constructor from Rester::Service::Middleware::Base

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rester/service/middleware/error_handling.rb', line 9

def call(env)
  error = catch(:error) {
    begin
      return super
    rescue Exception => error
      throw :error, error
    end
  }

  service.logger.error(error.inspect)
  _error_to_response(error).finish
end