Class: Logfoo::Rack::Err
- Inherits:
-
Object
- Object
- Logfoo::Rack::Err
- Defined in:
- lib/logfoo/integrations/rack/err.rb
Constant Summary collapse
- TEXT_PLAIN =
'text/plain'.freeze
- CLEAN_RE =
/\A(rack|puma|grape)\./.freeze
- FRAMEWORK_ERRORS =
%w{ action_dispatch.exception sinatra.error }.freeze
- INTERNAL_SERVER_ERROR =
[ 500, { R::CONTENT_TYPE => TEXT_PLAIN, R::CONTENT_LENGTH => R::Utils::HTTP_STATUS_CODES[500].bytesize }, [R::Utils::HTTP_STATUS_CODES[500]], ].freeze
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, log = nil) ⇒ Err
constructor
A new instance of Err.
Constructor Details
#initialize(app, log = nil) ⇒ Err
Returns a new instance of Err.
17 18 19 |
# File 'lib/logfoo/integrations/rack/err.rb', line 17 def initialize(app, log = nil) @app = app end |
Instance Method Details
#call(env) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/logfoo/integrations/rack/err.rb', line 21 def call(env) response = @app.call(env) if framework_error = FRAMEWORK_ERRORS.find { |k| env[k] } append(framework_error, env) end response rescue Exception => e append(e, env) INTERNAL_SERVER_ERROR end |