Class AxiomException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
BadGatewayException,BadRequestException,ConflictException,ForbiddenException,GatewayTimeoutException,GoneException,InternalServerErrorException,LengthRequiredException,MethodNotAllowedException,NotAcceptableException,NotFoundException,NotImplementedException,PayloadTooLargeException,PreconditionFailedException,PreconditionRequiredException,RequestHeaderFieldsTooLargeException,RequestTimeoutException,ServiceUnavailableException,TooManyRequestsException,UnauthorizedException,UnprocessableContentException,UnsupportedMediaTypeException,UriTooLongException
An Axiom exception carries only a final status (400-599), a short machine-readable code and,
for some subtypes, a list of field violations. These are the only values that
reach the response body, so they must never contain client input, internal messages or class
names. Codes are restricted to lowercase ASCII letters, digits, _, . and
- (at most 64 characters, starting with a letter) and are validated at construction. The
exception message is derived from the status and code alone. The only response headers an
exception can add are Allow, Retry-After and WWW-Authenticate, built by
subtypes from typed values and validated so they cannot inject other header fields. A cause
attached with Throwable.initCause(Throwable) is available to logging but is never sent to clients.
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAxiomException(int status) Creates the exception with the status's default code, for examplenot_found.protectedAxiomException(int status, String code) Creates the exception.protectedAxiomException(int status, String code, Map<String, String> headers) Creates the exception with response headers. -
Method Summary
Modifier and TypeMethodDescriptionfinal Stringcode()Returns the safe machine-readable code sent to clients.headers()Returns the headers this exception adds to its error response.final intstatus()Returns the response status.Returns field-level details sent to clients; empty unless a subtype provides them.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
AxiomException
protected AxiomException(int status) Creates the exception with the status's default code, for examplenot_found.- Parameters:
status- client or server error status, 400 through 599- Throws:
IllegalArgumentException- for an invalid status
-
AxiomException
Creates the exception.- Parameters:
status- client or server error status, 400 through 599code- safe machine-readable code- Throws:
IllegalArgumentException- for an invalid status or code
-
AxiomException
Creates the exception with response headers.- Parameters:
status- client or server error status, 400 through 599code- safe machine-readable codeheaders- values forAllow,Retry-AfterorWWW-Authenticateonly; visible ASCII, spaces and tabs, at most 1024 characters each- Throws:
IllegalArgumentException- for an invalid status, code, header name or value
-
-
Method Details
-
status
public final int status()Returns the response status.- Returns:
- status between 400 and 599
-
code
Returns the safe machine-readable code sent to clients.- Returns:
- error code
-
violations
Returns field-level details sent to clients; empty unless a subtype provides them.- Returns:
- immutable violations
-
headers
Returns the headers this exception adds to its error response.- Returns:
- immutable, case-insensitive headers; empty for most exceptions
-