Package com.tnsai.exceptions
Record Class ProviderDetails
java.lang.Object
java.lang.Record
com.tnsai.exceptions.ProviderDetails
- Record Components:
provider- non-null provider id (e.g."openai","anthropic")providerCode- provider-native error code (when surfaced)providerType- coarser provider-native error typeproviderParam- request parameter the error refers tohttpStatus- HTTP status when applicablerelevantHeaders- selected response headers (retry-after,x-request-id, etc.); empty when nonerawBody- full response body for forensics; pass through redaction before serialization
public record ProviderDetails(String provider, Optional<String> providerCode, Optional<String> providerType, Optional<String> providerParam, Optional<Integer> httpStatus, Map<String,String> relevantHeaders, String rawBody)
extends Record
Native error details surfaced from an upstream LLM (or external) provider.
When a provider returns a structured error body, the framework parses
the meaningful fields out and attaches them to LLMException via
this record. Consumers can then route on
providerCode() (e.g. "context_length_exceeded" →
summarize + retry, "rate_limit_exceeded" → backoff +
different model), and operators get provider-native fields in dashboards
for vendor-specific drill-down.
All fields except provider() are optional — providers vary
in how rich their error envelopes are, and HTTP-only failures (DNS,
connection reset) carry only a status code at best.
Example — OpenAI error body
{
"error": {
"message": "...",
"type": "invalid_request_error",
"code": "context_length_exceeded",
"param": "messages"
}
}
Maps to:
new ProviderDetails(
"openai",
Optional.of("context_length_exceeded"),
Optional.of("invalid_request_error"),
Optional.of("messages"),
Optional.of(400),
Map.of("openai-version", "2026-04-01"),
"<raw response body, redaction applied>")
- Since:
- 0.5.0 (issue #87)
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ProviderDetails.Builderfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of thehttpStatusrecord component.static ProviderDetailsConstruct minimal details — just the provider id.provider()Returns the value of theproviderrecord component.Returns the value of theproviderCoderecord component.Returns the value of theproviderParamrecord component.Returns the value of theproviderTyperecord component.rawBody()Returns the value of therawBodyrecord component.Returns the value of therelevantHeadersrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ProviderDetails
public ProviderDetails(String provider, Optional<String> providerCode, Optional<String> providerType, Optional<String> providerParam, Optional<Integer> httpStatus, Map<String, String> relevantHeaders, String rawBody) Creates an instance of aProviderDetailsrecord class.- Parameters:
provider- the value for theproviderrecord componentproviderCode- the value for theproviderCoderecord componentproviderType- the value for theproviderTyperecord componentproviderParam- the value for theproviderParamrecord componenthttpStatus- the value for thehttpStatusrecord componentrelevantHeaders- the value for therelevantHeadersrecord componentrawBody- the value for therawBodyrecord component
-
-
Method Details
-
of
Construct minimal details — just the provider id. Useful when the provider returned no structured envelope (transport-layer failure). -
builder
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
provider
Returns the value of theproviderrecord component.- Returns:
- the value of the
providerrecord component
-
providerCode
Returns the value of theproviderCoderecord component.- Returns:
- the value of the
providerCoderecord component
-
providerType
Returns the value of theproviderTyperecord component.- Returns:
- the value of the
providerTyperecord component
-
providerParam
Returns the value of theproviderParamrecord component.- Returns:
- the value of the
providerParamrecord component
-
httpStatus
Returns the value of thehttpStatusrecord component.- Returns:
- the value of the
httpStatusrecord component
-
relevantHeaders
Returns the value of therelevantHeadersrecord component.- Returns:
- the value of the
relevantHeadersrecord component
-
rawBody
Returns the value of therawBodyrecord component.- Returns:
- the value of the
rawBodyrecord component
-