Exception: ClaudeSDK::CLIJSONDecodeError

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

Overview

Raised when unable to decode JSON from CLI output

Examples:

raise CLIJSONDecodeError.new("invalid json", original_error: JSON::ParserError.new)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line:, original_error:) ⇒ CLIJSONDecodeError

Returns a new instance of CLIJSONDecodeError.

Parameters:

  • line (String)

    the line that failed to decode

  • original_error (Exception)

    the original JSON parsing error



69
70
71
72
73
# File 'lib/claude_sdk/errors.rb', line 69

def initialize(line:, original_error:)
  @line = line
  @original_error = original_error
  super("Failed to decode JSON: #{line[0..99]}...")
end

Instance Attribute Details

#lineString (readonly)

Returns the line that failed to decode.

Returns:

  • (String)

    the line that failed to decode



62
63
64
# File 'lib/claude_sdk/errors.rb', line 62

def line
  @line
end

#original_errorException (readonly)

Returns the original JSON parsing error.

Returns:

  • (Exception)

    the original JSON parsing error



65
66
67
# File 'lib/claude_sdk/errors.rb', line 65

def original_error
  @original_error
end