Module: Anthropic::Models::ErrorObject

Extended by:
Internal::Type::Union
Defined in:
lib/anthropic/models/error_object.rb,
sig/anthropic/models/error_object.rbs

Defined Under Namespace

Modules: Type

Class Method Summary collapse

Methods included from Internal::Type::Union

==, ===, coerce, derefed_variants, dump, hash, inspect, to_sorbet_type

Methods included from Internal::Util::SorbetRuntimeSupport

#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type

Methods included from Internal::Type::Converter

#coerce, coerce, #dump, dump, inspect, #inspect, meta_info, new_coerce_state, type_info

Class Method Details

.new(type:, message:) ⇒ Anthropic::InvalidRequestErrorObject .new(type:, message:) ⇒ Anthropic::AuthenticationErrorObject .new(type:, message:) ⇒ Anthropic::BillingErrorObject .new(type:, message:) ⇒ Anthropic::PermissionErrorObject .new(type:, message:) ⇒ Anthropic::NotFoundErrorObject .new(type:, message:) ⇒ Anthropic::RateLimitErrorObject .new(type:, message:) ⇒ Anthropic::GatewayTimeoutErrorObject .new(type:, message:) ⇒ Anthropic::APIErrorObject .new(type:, message:) ⇒ Anthropic::OverloadedErrorObject .new(type:, message:) ⇒ Anthropic::Models::error_object

Creates a new instance of the variant class whose type matches the given value, passing the remaining arguments to its constructor.

Some parameter documentations has been truncated, see Anthropic::Models::ErrorObject for more details.

Overloads:

Parameters:

  • type (Symbol, Anthropic::Models::ErrorObject::Type, String)
  • args (Hash{Symbol=>Object}) —

    Attributes for the chosen variant.

    @option args [String] :message A human-readable explanation of the error. Its wording can change, so don't matc

Returns:

Raises:

  • (ArgumentError)


62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/anthropic/models/error_object.rb', line 62

def self.new(type:, **args)
  case type.to_sym
  when :invalid_request_error
    Anthropic::InvalidRequestErrorObject.new(**args)
  when :authentication_error
    Anthropic::AuthenticationErrorObject.new(**args)
  when :billing_error
    Anthropic::BillingErrorObject.new(**args)
  when :permission_error
    Anthropic::PermissionErrorObject.new(**args)
  when :not_found_error
    Anthropic::NotFoundErrorObject.new(**args)
  when :rate_limit_error
    Anthropic::RateLimitErrorObject.new(**args)
  when :timeout_error
    Anthropic::GatewayTimeoutErrorObject.new(**args)
  when :api_error
    Anthropic::APIErrorObject.new(**args)
  when :overloaded_error
    Anthropic::OverloadedErrorObject.new(**args)
  else
    raise ArgumentError, "unknown type: #{type}"
  end
end

.values ⇒ Array<Symbol>

Returns:

  • (Array<Symbol>)


# File 'lib/anthropic/models/error_object.rb', line 41