Class: Hanami::Middleware::RenderErrors Private

Inherits:
Object
  • Object
show all
Defined in:
lib/hanami/middleware/render_errors.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Rack middleware that rescues errors raised by the app renders friendly error responses, via a given “errors app”.

By default, this is enabled only in production mode.

See Also:

Since:

  • 2.1.0

Defined Under Namespace

Classes: RenderableException

Instance Method Summary collapse

Constructor Details

#initialize(app, config, errors_app) ⇒ RenderErrors

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of RenderErrors.

Since:

  • 2.1.0



48
49
50
51
52
# File 'lib/hanami/middleware/render_errors.rb', line 48

def initialize(app, config, errors_app)
  @app = app
  @config = config
  @errors_app = errors_app
end

Instance Method Details

#call(env) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.1.0



56
57
58
59
60
61
62
# File 'lib/hanami/middleware/render_errors.rb', line 56

def call(env)
  @app.call(env)
rescue Exception => exception
  raise unless @config.render_errors

  render_exception(env, exception)
end