Exception: Anthropic::Errors::ConversionError

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

Instance Method Summary collapse

Constructor Details

#initialize(on:, method:, target:, value:, cause: nil) ⇒ ConversionError

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ConversionError.

Parameters:

  • on (Class<StandardError>)
  • method (Symbol)
  • target (Object)
  • value (Object)
  • cause (StandardError, nil) (defaults to: nil)


22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/anthropic/errors.rb', line 22

def initialize(on:, method:, target:, value:, cause: nil)
  cls = on.name.split("::").last

  message = [
    "Failed to parse #{cls}.#{method} from #{value.class} to #{target.inspect}.",
    "To get the unparsed API response, use #{cls}[#{method.inspect}].",
    cause && "Cause: #{cause.message}"
  ].filter(&:itself).join(" ")

  @cause = cause
  super(message)
end

Instance Method Details

#causeStandardError?

Returns:

  • (StandardError, nil)


13
# File 'lib/anthropic/errors.rb', line 13

def cause = @cause.nil? ? super : @cause