Class: SolidLoop::Middlewares::ErrorHandling
- Inherits:
-
Object
- Object
- SolidLoop::Middlewares::ErrorHandling
- Defined in:
- app/services/solid_loop/middlewares/error_handling.rb
Constant Summary collapse
- GRACEFUL_ERRORS =
[ SolidLoop::CancellationError, SolidLoop::LimitExceededError, SolidLoop::McpError, Faraday::Error, JSON::ParserError ].freeze
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ ErrorHandling
constructor
A new instance of ErrorHandling.
Constructor Details
#initialize(app) ⇒ ErrorHandling
Returns a new instance of ErrorHandling.
4 5 6 |
# File 'app/services/solid_loop/middlewares/error_handling.rb', line 4 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/services/solid_loop/middlewares/error_handling.rb', line 16 def call(env) begin @app.call(env) # Only raise the exception if one of the inner middlewares caught it but didn't re-raise # (although inner layers shouldn't rescue unless they fully handle it, some might put it in env.exception) raise env.exception if env.exception rescue StandardError => e raise e unless graceful_error?(e) handle_exception(env, e) end end |