java.lang.Object
is.codion.framework.json.db.ErrorEnvelope
The body of a JSON error response, the wire form of a server side exception.
Carries a closed ErrorKind, a message, a correlation id linking the response to a server log entry,
and a kind specific detail node for the kinds whose exception cannot be reconstructed from a message alone.
A database exception based on an error type carries the name of the errorType and the errorDetail,
if any, with which the client puts the message together in its own language, the message being in the language
of the server.
Neither a stack trace nor a cause chain is ever carried, in either direction. A client reconstructing an
exception from an envelope maps the kind() to a known constructor; nothing on the wire names a class.
{
"kind" : "CONFLICT_REFERENTIAL",
"message" : "This record is referenced by records in other tables, delete those first: EMP_DEPT_FK",
"correlationId" : "b1f4c8e2-3a1d-4f0b-9c5e-7d2a6f8b1c3e",
"detail" : { "operation" : "DELETE" },
"errorType" : "CHILD_EXISTS",
"errorDetail" : "EMP_DEPT_FK"
}
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThedetailfield listing the modified columns of aErrorKind.CONFLICT_MODIFIEDentity, asentityTypeName.columnName.static final StringThedetailfield carrying the entity aErrorKind.CONFLICT_MODIFIEDwas thrown for.static final StringThedetailfield carrying the current state of aErrorKind.CONFLICT_MODIFIEDentity, null if deleted.static final StringThedetailfield naming the operation aErrorKind.CONFLICT_REFERENTIALprevented. -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
OPERATION
Thedetailfield naming the operation aErrorKind.CONFLICT_REFERENTIALprevented.- See Also:
-
ENTITY
Thedetailfield carrying the entity aErrorKind.CONFLICT_MODIFIEDwas thrown for.- See Also:
-
MODIFIED
Thedetailfield carrying the current state of aErrorKind.CONFLICT_MODIFIEDentity, null if deleted.- See Also:
-
COLUMNS
Thedetailfield listing the modified columns of aErrorKind.CONFLICT_MODIFIEDentity, asentityTypeName.columnName.- See Also:
-
-
Constructor Details
-
ErrorEnvelope
public ErrorEnvelope(String kind, String message, String correlationId, @Nullable com.fasterxml.jackson.databind.JsonNode detail, @Nullable String errorType, @Nullable String errorDetail) - Parameters:
kind- theErrorKindname, a string rather than the enum so an unknown kind does not fail to parsemessage- the error messagecorrelationId- identifies the server log entry describing this errordetail- kind specific detail, null if the kind carries noneerrorType- the name of theErrorTypea database exception is based on, a string rather than the enum so an unknown error type does not fail to parse, null if it is not based on oneerrorDetail- the error detail of a database exception based on an error type, null if none
-
-
Method Details
-
kind
- Returns:
- the
ErrorKindname, seeerrorKind()
-
message
- Returns:
- the error message
-
correlationId
- Returns:
- the id identifying the server log entry describing this error
-
detail
- Returns:
- the kind specific detail, or null if the kind carries none
-
errorType
Returns the name of the error type a database exception is based on. With it the client puts the message together in its own language,message()being in the language of the server. A client not knowing the error type, one older than the server, or one not written in Java and not localizing, usesmessage().- Returns:
- the name of the
ErrorType, null if the exception is not based on one - See Also:
-
errorDetail
- Returns:
- the error detail, the name of a constraint, column or table for example, null if none
- See Also:
-
errorKind
-
toString
-
toJson
- Returns:
- this envelope as a JSON string
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- in case of an error
-
fromJson
- Parameters:
json- the JSON to parse- Returns:
- the
ErrorEnvelopethe given JSON represents - Throws:
IOException- in case the given JSON is not an error envelope
-