Class: Ditty::Middleware::ErrorCatchall

Inherits:
Object
  • Object
show all
Defined in:
lib/ditty/middleware/error_catchall.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ErrorCatchall

Returns a new instance of ErrorCatchall.



10
11
12
# File 'lib/ditty/middleware/error_catchall.rb', line 10

def initialize(app)
  @app = app
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



8
9
10
# File 'lib/ditty/middleware/error_catchall.rb', line 8

def env
  @env
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/ditty/middleware/error_catchall.rb', line 14

def call(env)
  @env = env
  begin
    @app.call env
  rescue StandardError => e
    ::Ditty::Services::Logger.error "Ditty Catchall: #{e.class}"
    ::Ditty::Services::Logger.error e
    [500, {}, ['Unknown Error']]
  end
end