Every exception the gem defines inherits from Scute::Error (a StandardError).
begin scute.users.merge(user_id, from: old_id)rescue Scute::APIError => e e.status # 409 e.code # "already_merged" e.body # the API's answer, parsedrescue Scute::ConnectionError # Scute could not be reachedendClasses#
| Class | Raised when | Attributes |
|---|---|---|
| Scute::APIError | Scute answered 4xx or 5xx. | status, code (the API's error_code), body |
| Scute::ConnectionError | Scute could not be reached: connection refused or reset, host unreachable, timeout, DNS, TLS. Raised after the retries for idempotent calls. | none |
| Scute::ConfigurationError | Something needed for the call is missing: the app id, the secret key, or a task token for a harness run. | none |
| Scute::InvalidToken | tokens.verify refused the token. | reason |
| Scute::Unauthenticated | scute_authenticate! found no valid session, or scute_authorize! ran with nobody signed in. Same class as Scute::Authentication::Unauthenticated. | reason |
| Scute::Forbidden | scute_authorize! got an answer that is not a plain allow. Same class as Scute::Authorization::Forbidden. | decision |
ArgumentError (from Ruby) is raised for bad input before any request: a client_ip that is not one address, more than 100 checks in check_batch, start_step_up without a permission or method, a decide_request verdict other than :approve or :deny.
Scute::APIError#
The message is the API's error, then its say, then "Scute answered <status>". code is nil when the answer has no error_code.
Codes the SDK itself reacts to:
| Code | Where |
|---|---|
| already_merged | users.merge on an account merged before. |
| task_closed (status 409) | A harness run whose task is over. Raised by the SDK; start a new run. |
| invalid_task_token (status 401) | A task token Scute says is dead before its expiry (revoked, completed, agent suspended). The run closes for good. |
| not_verified (status 409) | run.complete_verification before the verification completed. Raised by the SDK. |
Scute::InvalidToken reasons#
| reason | Meaning |
|---|---|
| :missing | No token. |
| :malformed | Not a JWT, or no exp. |
| :algorithm | Not RS256 (including alg: none). |
| :signature | The signature matches none of the app's keys. |
| :expired | exp is more than 30 seconds in the past. |
| :wrong_app | The token is for another app. |
| :not_a_user | Not a user's session (an M2M token, or no uuid). |
| :revoked | remote: true and Scute says the session has ended. |
Scute::Unauthenticated#reason carries the same symbol. Its default message is "Sign in first" with reason :missing.
Scute::Forbidden#
The message is decision.explanation, or "Not allowed (<reason>)" when there is none. decision is a Scute::Authz::Decision:
rescue_from Scute::Forbidden do |e| if e.decision.step_up? then render json: { step_up: e.decision.step_up }, status: :forbidden elsif e.decision.needs_approval? then render json: { approval: true }, status: :forbidden else render json: { error: e.message }, status: :forbidden endendIn a harness run#
Guards do not raise into your tool code. A call that may not run returns a message for the model instead (from run.wrap, or { error: ... } from the RubyLLM adapter). A guard that raises counts as deny.