Class: SolidLoop::ToolMiddlewares::ErrorHandling

Inherits:
Object
  • Object
show all
Defined in:
app/services/solid_loop/tool_middlewares/error_handling.rb

Constant Summary collapse

GRACEFUL_ERRORS =

Errors the tool path terminalizes in-line (loop → failed) and then SWALLOWS (never re-raised), so ActiveJob does not retry a durable, already-recorded failure. Everything else re-raises to the job-level reconciliation wrapper (findings 4/9), which fails the loop under the BOTH-token fence — closing the "stranded running" gap for a renamed agent method or a middleware bug. A CancellationError is fenceless: it fires precisely when this generation already lost the token (pause/stop).

[
  SolidLoop::CancellationError,
  SolidLoop::McpError
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ErrorHandling

Returns a new instance of ErrorHandling.



4
5
6
# File 'app/services/solid_loop/tool_middlewares/error_handling.rb', line 4

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/services/solid_loop/tool_middlewares/error_handling.rb', line 20

def call(env)
  begin
    @app.call(env)
    # Re-raise if exception was caught by inner layer but left in env
    raise env.exception if env.exception
  rescue StandardError => e
    raise e unless graceful_error?(e)

    handle_exception(env, e)
    # Swallowed: expose it for outer inspection (tests) but do NOT re-raise
    # — the failure is already durable in the DB.
    env.exception = e
  end
end