Class ErrorObject
-
- All Implemented Interfaces:
public final class ErrorObject
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceErrorObject.VisitorAn interface that defines how to map each variant of ErrorObject to a value of type T.
public final classErrorObject.Type
-
Method Summary
-
-
Method Detail
-
invalidRequestError
final Optional<InvalidRequestError> invalidRequestError()
-
authenticationError
final Optional<AuthenticationError> authenticationError()
-
billingError
final Optional<BillingError> billingError()
-
permissionError
final Optional<PermissionError> permissionError()
-
notFoundError
final Optional<NotFoundError> notFoundError()
-
rateLimitError
final Optional<RateLimitError> rateLimitError()
-
timeoutError
final Optional<GatewayTimeoutError> timeoutError()
-
apiError
final Optional<ApiErrorObject> apiError()
-
overloadedError
final Optional<OverloadedError> overloadedError()
-
type
final ErrorObject.Type type()
-
isInvalidRequestError
final Boolean isInvalidRequestError()
-
isAuthenticationError
final Boolean isAuthenticationError()
-
isBillingError
final Boolean isBillingError()
-
isPermissionError
final Boolean isPermissionError()
-
isNotFoundError
final Boolean isNotFoundError()
-
isRateLimitError
final Boolean isRateLimitError()
-
isTimeoutError
final Boolean isTimeoutError()
-
isApiError
final Boolean isApiError()
-
isOverloadedError
final Boolean isOverloadedError()
-
asInvalidRequestError
final InvalidRequestError asInvalidRequestError()
-
asAuthenticationError
final AuthenticationError asAuthenticationError()
-
asBillingError
final BillingError asBillingError()
-
asPermissionError
final PermissionError asPermissionError()
-
asNotFoundError
final NotFoundError asNotFoundError()
-
asRateLimitError
final RateLimitError asRateLimitError()
-
asTimeoutError
final GatewayTimeoutError asTimeoutError()
-
asApiError
final ApiErrorObject asApiError()
-
asOverloadedError
final OverloadedError asOverloadedError()
-
accept
final <T extends Any> T accept(ErrorObject.Visitor<T> visitor)
Maps this instance's current variant to a value of type T using the given visitor.
Note that this method is not forwards compatible with new variants from the API, unless visitor overrides Visitor.unknown. To handle variants not known to this version of the SDK gracefully, consider overriding Visitor.unknown:
import com.anthropic.core.JsonValue; import java.util.Optional; Optional<String> result = errorObject.accept(new ErrorObject.Visitor<Optional<String>>() { @Override public Optional<String> visitInvalidRequestError(InvalidRequestError invalidRequestError) { return Optional.of(invalidRequestError.toString()); } // ... @Override public Optional<String> unknown(JsonValue json) { // Or inspect the `json`. return Optional.empty(); } });
-
validate
final ErrorObject validate()
Validates that the types of all values in this object match their expected types recursively.
This method is not forwards compatible with new types from the API for existing fields.
-
ofInvalidRequestError
final static ErrorObject ofInvalidRequestError(InvalidRequestError invalidRequestError)
-
ofInvalidRequestError
final static ErrorObject ofInvalidRequestError(String message)
Returns an immutable instance of ErrorObject whose ofInvalidRequestError variant is built from the given required message.
-
ofAuthenticationError
final static ErrorObject ofAuthenticationError(AuthenticationError authenticationError)
-
ofAuthenticationError
final static ErrorObject ofAuthenticationError(String message)
Returns an immutable instance of ErrorObject whose ofAuthenticationError variant is built from the given required message.
-
ofBillingError
final static ErrorObject ofBillingError(BillingError billingError)
-
ofBillingError
final static ErrorObject ofBillingError(String message)
Returns an immutable instance of ErrorObject whose ofBillingError variant is built from the given required message.
-
ofPermissionError
final static ErrorObject ofPermissionError(PermissionError permissionError)
-
ofPermissionError
final static ErrorObject ofPermissionError(String message)
Returns an immutable instance of ErrorObject whose ofPermissionError variant is built from the given required message.
-
ofNotFoundError
final static ErrorObject ofNotFoundError(NotFoundError notFoundError)
-
ofNotFoundError
final static ErrorObject ofNotFoundError(String message)
Returns an immutable instance of ErrorObject whose ofNotFoundError variant is built from the given required message.
-
ofRateLimitError
final static ErrorObject ofRateLimitError(RateLimitError rateLimitError)
-
ofRateLimitError
final static ErrorObject ofRateLimitError(String message)
Returns an immutable instance of ErrorObject whose ofRateLimitError variant is built from the given required message.
-
ofTimeoutError
final static ErrorObject ofTimeoutError(GatewayTimeoutError timeoutError)
-
ofTimeoutError
final static ErrorObject ofTimeoutError(String message)
Returns an immutable instance of ErrorObject whose ofTimeoutError variant is built from the given required message.
-
ofApiError
final static ErrorObject ofApiError(ApiErrorObject apiError)
-
ofApiError
final static ErrorObject ofApiError(String message)
Returns an immutable instance of ErrorObject whose ofApiError variant is built from the given required message.
-
ofOverloadedError
final static ErrorObject ofOverloadedError(OverloadedError overloadedError)
-
ofOverloadedError
final static ErrorObject ofOverloadedError(String message)
Returns an immutable instance of ErrorObject whose ofOverloadedError variant is built from the given required message.
-
-
-
-