Package org.mockserver.grpc.connect
Class ConnectError
java.lang.Object
org.mockserver.grpc.connect.ConnectError
A Connect protocol (buf.build Connect) unary error.
Connect unary errors are returned as a non-200 HTTP response with a JSON body of the shape:
{
"code": "not_found",
"message": "...",
"details": [ ... ]
}
where code is one of the canonical Connect error code strings. Connect error codes are the
lower-case snake_case forms of the gRPC status names (e.g. gRPC INVALID_ARGUMENT ->
Connect invalid_argument), and each maps to a specific HTTP status code per the Connect
specification (https://connectrpc.com/docs/protocol#error-codes).
The HTTP status mapping mirrors the Connect reference implementation's codeToHTTP
(connectrpc/connect-go), which is in turn consistent with GrpcStatusMapper.
There is no Connect code for gRPC OK; a successful unary response is an HTTP 200 with the
message body, not an error envelope.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe canonical Connect error codes. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ConnectErrorconnectError(String code, String message) static ConnectErrorconnectError(ConnectError.Code code, String message) getCode()intThe HTTP status this error maps to, resolved viaConnectError.Code.fromString(String)so an unrecognised or null code degrades to theunknownmapping (HTTP 500).setDetails(List<Object> details) setMessage(String message)
-
Constructor Details
-
ConnectError
public ConnectError() -
ConnectError
-
-
Method Details
-
connectError
-
connectError
-
getCode
-
setCode
-
getMessage
-
setMessage
-
getDetails
-
setDetails
-
addDetail
-
httpStatus
public int httpStatus()The HTTP status this error maps to, resolved viaConnectError.Code.fromString(String)so an unrecognised or null code degrades to theunknownmapping (HTTP 500).
-