Exception: ClaudeSDK::ProcessError

Inherits:
Error
  • Object
show all
Defined in:
lib/claude_sdk/errors.rb

Overview

Raised when the CLI process fails

Examples:

raise ProcessError.new("Command failed", exit_code: 1, stderr: "Error output")

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, exit_code: nil, stderr: nil) ⇒ ProcessError

Returns a new instance of ProcessError.

Parameters:

  • message (String)

    the error message

  • exit_code (Integer, nil) (defaults to: nil)

    the process exit code

  • stderr (String, nil) (defaults to: nil)

    the stderr output



45
46
47
48
49
50
51
52
53
# File 'lib/claude_sdk/errors.rb', line 45

def initialize(message, exit_code: nil, stderr: nil)
  @exit_code = exit_code
  @stderr = stderr

  message = "#{message} (exit code: #{exit_code})" if exit_code
  message = "#{message}\nError output: #{stderr}" if stderr

  super(message)
end

Instance Attribute Details

#exit_codeInteger? (readonly)

Returns the process exit code.

Returns:

  • (Integer, nil)

    the process exit code



37
38
39
# File 'lib/claude_sdk/errors.rb', line 37

def exit_code
  @exit_code
end

#stderrString? (readonly)

Returns the stderr output from the process.

Returns:

  • (String, nil)

    the stderr output from the process



40
41
42
# File 'lib/claude_sdk/errors.rb', line 40

def stderr
  @stderr
end