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.
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" : "Delete failed, the record is referenced by another record",
"correlationId" : "b1f4c8e2-3a1d-4f0b-9c5e-7d2a6f8b1c3e",
"detail" : { "operation" : "DELETE" }
}
- 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
ConstructorsConstructorDescriptionErrorEnvelope(String kind, String message, String correlationId, @Nullable com.fasterxml.jackson.databind.JsonNode detail) -
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) - 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 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
-
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
-