Canonical error type for ClaudeWrapper.
Every operational failure in this library is returned as
{:error, %ClaudeWrapper.Error{}} and can also be raised (it is a
proper exception). Branch on the :kind atom for the failure
category; the :reason field plus the dedicated :exit_code /
:stdout / :stderr fields carry the details.
case ClaudeWrapper.query("hi") do
{:ok, result} -> result
{:error, %ClaudeWrapper.Error{kind: :max_turns_exceeded}} -> :hit_limit
{:error, %ClaudeWrapper.Error{kind: :command_failed, exit_code: code}} -> code
endThe variant set mirrors the Rust claude-wrapper Error enum.
Kinds
:binary_not_found-- theclaudebinary could not be launched:command_failed-- the CLI exited non-zero (:exit_code,:stdout,:stderr):io-- an OS/IO error launching or talking to the CLI (:reason):timeout-- the call exceeded its timeout (:reasonis the timeout in ms):json-- the CLI output could not be decoded as JSON (:reason, optional:stdout):max_turns_exceeded-- the CLI stopped at its--max-turnslimit:version_mismatch-- the CLI is older than a required minimum (:reasonis%{found:, minimum:}):invalid_version-- a version string could not be parsed (:reasonis the original string):budget_exceeded-- a client-side budget ceiling was hit (:reasonis%{total_usd:, max_usd:}):dangerous_not_allowed-- a bypass query was attempted without the opt-in env var (:reasonis the env var name):duplex_closed-- the duplex session port was already closed:turn_in_flight-- a turn is already running on the session:duplex_control_failed-- an interrupt/permission control message failed (:reason):terminated-- the session terminated while a turn was pending:cannot_defer_again-- a permission decision was deferred twice:no_session-- a REPL helper was used with no active session:not_found-- a requested resource does not exist (:reasonidentifies it):already_exists-- a create-new target already exists (:reason):invalid_stem-- an invalid file stem / identifier (:reason):no_home-- the user home directory could not be determined:invalid_settings_json-- a settings file is not valid JSON (:reasonis%{path:, error:}):settings_read_error-- a settings file could not be read (:reasonis%{path:, error:}):not_a_git_repo-- a path is not inside a git repo (:reasonis the path):git_failed-- agitinvocation failed (:reason):git_unavailable-- thegitbinary is not available (:reason):invalid_tool_pattern-- a tool pattern failed validation (:reasonis the specific problem):auth-- an authentication failure, classified into:reason(seeClaudeWrapper.Auth.auth_error_kind/0)
Summary
Functions
A :command_failed error from a non-zero CLI exit.
An :io error wrapping an underlying reason.
A :json decode error, optionally carrying the raw stdout.
Build an error of kind, with optional :message, :reason,
:exit_code, :stdout, :stderr.
A :timeout error (ms is the elapsed timeout).
Types
@type kind() ::
:binary_not_found
| :command_failed
| :io
| :timeout
| :json
| :max_turns_exceeded
| :version_mismatch
| :invalid_version
| :budget_exceeded
| :dangerous_not_allowed
| :duplex_closed
| :turn_in_flight
| :duplex_control_failed
| :terminated
| :cannot_defer_again
| :no_session
| :not_found
| :already_exists
| :invalid_stem
| :no_home
| :invalid_settings_json
| :settings_read_error
| :not_a_git_repo
| :git_failed
| :git_unavailable
| :invalid_tool_pattern
| :auth
Functions
A :command_failed error from a non-zero CLI exit.
An :io error wrapping an underlying reason.
A :json decode error, optionally carrying the raw stdout.
Build an error of kind, with optional :message, :reason,
:exit_code, :stdout, :stderr.
@spec timeout(non_neg_integer()) :: t()
A :timeout error (ms is the elapsed timeout).