- All Implemented Interfaces:
Serializable,Comparable<TrpcErrorCode>,Constable
Maps standard Jooby HTTP status codes to official tRPC error codes.
The tRPC specification dictates that failed requests must return specific JSON-RPC style
integer codes (e.g., -32600) in the JSON response payload, alongside the standard HTTP status
codes. This enumeration defines the canonical mapping between Jooby's StatusCode and the
expected tRPC error shape.
When an exception is thrown within a tRPC route, Jooby uses this mapping to format the error
response so the frontend @trpc/client can correctly parse and reconstruct the
TRPCClientError.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionInvalid routing or parameters.The client disconnected before the server could respond.State conflict, such as a duplicate database entry.Authenticated user lacks required permissions.Internal server error.The HTTP method used is not supported by the procedure (e.g., GET on a mutation).The requested resource or tRPC procedure was not found.The server received invalid JSON.The incoming request payload exceeds the allowed limits.The client's preconditions were not met.The request took too long to process.Rate limiting applied.Missing or invalid authentication.The payload format is valid, but the content is semantically incorrect. -
Method Summary
Modifier and TypeMethodDescriptionintRetrieves the JSON-RPC style integer code.io.jooby.StatusCodeRetrieves the corresponding HTTP status code.static TrpcErrorCodeof(io.jooby.StatusCode status) Resolves the closest tRPC error code for a given Jooby HTTP status code.static TrpcErrorCodeReturns the enum constant of this class with the specified name.static TrpcErrorCode[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class java.lang.Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
BAD_REQUEST
Invalid routing or parameters. Mapped to HTTP 400. -
PARSE_ERROR
The server received invalid JSON. Mapped to HTTP 400. -
INTERNAL_SERVER_ERROR
Internal server error. Mapped to HTTP 500. -
UNAUTHORIZED
Missing or invalid authentication. Mapped to HTTP 401. -
FORBIDDEN
Authenticated user lacks required permissions. Mapped to HTTP 403. -
NOT_FOUND
The requested resource or tRPC procedure was not found. Mapped to HTTP 404. -
METHOD_NOT_SUPPORTED
The HTTP method used is not supported by the procedure (e.g., GET on a mutation). Mapped to HTTP 405. -
TIMEOUT
The request took too long to process. Mapped to HTTP 408. -
CONFLICT
State conflict, such as a duplicate database entry. Mapped to HTTP 409. -
PRECONDITION_FAILED
The client's preconditions were not met. Mapped to HTTP 412. -
PAYLOAD_TOO_LARGE
The incoming request payload exceeds the allowed limits. Mapped to HTTP 413. -
UNPROCESSABLE_CONTENT
The payload format is valid, but the content is semantically incorrect. Mapped to HTTP 422. -
TOO_MANY_REQUESTS
Rate limiting applied. Mapped to HTTP 429. -
CLIENT_CLOSED_REQUEST
The client disconnected before the server could respond. Mapped to HTTP 499.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getRpcCode
public int getRpcCode()Retrieves the JSON-RPC style integer code.- Returns:
- The tRPC integer code (e.g., -32600).
-
getStatusCode
public io.jooby.StatusCode getStatusCode()Retrieves the corresponding HTTP status code.- Returns:
- The Jooby
StatusCode.
-
of
Resolves the closest tRPC error code for a given Jooby HTTP status code.If an exact match is not found for the provided HTTP status, this method falls back to
INTERNAL_SERVER_ERROR.- Parameters:
status- The Jooby HTTP status code.- Returns:
- The corresponding
TrpcErrorCode, orINTERNAL_SERVER_ERRORif no match exists.
-