Exception: Anthropic::Credentials::WorkloadIdentityError

Inherits:
Errors::Error
  • Object
show all
Defined in:
lib/anthropic/credentials/workload_identity.rb

Overview

Raised when the OIDC token exchange (+POST /v1/oauth/token+) fails.

This error includes additional diagnostic information from the token endpoint response to help debug federation configuration issues.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, status_code: nil, body: nil, request_id: nil) ⇒ WorkloadIdentityError

Returns a new instance of WorkloadIdentityError.

Parameters:

  • message (String)

    error description

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

    HTTP status code

  • body (Hash, String, nil) (defaults to: nil)

    response body (will be included in error details)

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

    request ID for debugging



23
24
25
26
27
28
# File 'lib/anthropic/credentials/workload_identity.rb', line 23

def initialize(message, status_code: nil, body: nil, request_id: nil)
  super(message)
  @status_code = status_code
  @body = body
  @request_id = request_id
end

Instance Attribute Details

#bodyHash, ... (readonly)

Returns error body from the token endpoint (redacted for safety).

Returns:

  • (Hash, String, nil)

    error body from the token endpoint (redacted for safety)



14
15
16
# File 'lib/anthropic/credentials/workload_identity.rb', line 14

def body
  @body
end

#request_idString? (readonly)

Returns request ID from the token endpoint response headers.

Returns:

  • (String, nil)

    request ID from the token endpoint response headers



17
18
19
# File 'lib/anthropic/credentials/workload_identity.rb', line 17

def request_id
  @request_id
end

#status_codeInteger? (readonly)

Returns HTTP status code from the token endpoint, if available.

Returns:

  • (Integer, nil)

    HTTP status code from the token endpoint, if available



11
12
13
# File 'lib/anthropic/credentials/workload_identity.rb', line 11

def status_code
  @status_code
end

Instance Method Details

#to_sString

Returns formatted error message including request ID if available.

Returns:

  • (String)

    formatted error message including request ID if available



31
32
33
34
# File 'lib/anthropic/credentials/workload_identity.rb', line 31

def to_s
  base = super
  request_id ? "#{base} [request_id=#{request_id}]" : base
end