Package org.kiwiproject.jaxrs.exception
Class ErrorMessage
java.lang.Object
org.kiwiproject.jaxrs.exception.ErrorMessage
An error message that kiwi uses in Jakarta REST related utilities. This is effectively a replacement for the
Dropwizard class of the same name.
Each instance contains the HTTP status (error) code; the error message; an optional identifier to identify the specific item causing the error (e.g. a primary key); and an optional field/property name for cases when a specific field causes the error.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionErrorMessage(int code, String message) Create instance with the given HTTP status code and message.ErrorMessage(int code, String message, String fieldName) Create instance with the given HTTP status code, message, and field/property name.ErrorMessage(jakarta.ws.rs.core.Response.Status status, String message) Create instance with the given HTTP status and message.ErrorMessage(String message) Create instance with the given message and the default status code (500).ErrorMessage(String itemId, int code, String message, String fieldName) Create instance with the given item identifier, HTTP status code, message, and field/property name. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleanintgetCode()inthashCode()toMap()Convert this instance to a map.toString()static ErrorMessageBuild anErrorMessagefrom the given map of properties, whose keys must correspond to the property names and whose values must have the expected type.
-
Field Details
-
KEY_CODE
- See Also:
-
KEY_FIELD_NAME
- See Also:
-
KEY_ITEM_ID
- See Also:
-
KEY_MESSAGE
- See Also:
-
-
Constructor Details
-
ErrorMessage
Create instance with the given message and the default status code (500).- Parameters:
message- the error message
-
ErrorMessage
Create instance with the given HTTP status and message.- Parameters:
status- the HTTP response statusmessage- the error message
-
ErrorMessage
Create instance with the given HTTP status code and message.- Parameters:
code- the HTTP status codemessage- the error message
-
ErrorMessage
Create instance with the given HTTP status code, message, and field/property name.- Parameters:
code- the HTTP status codemessage- the error messagefieldName- the field/property name that caused this error
-
ErrorMessage
@ConstructorProperties({"itemId","code","message","fieldName"}) public ErrorMessage(String itemId, int code, String message, String fieldName) Create instance with the given item identifier, HTTP status code, message, and field/property name.Note that only this constructor has been marked with
ConstructorPropertiesdue to an open (as of 2020-09-02) issue in Jackson Databind. See jackson-databind issue #1514.- Parameters:
itemId- the unique ID of the item that caused this errorcode- the HTTP status codemessage- the error messagefieldName- the field/property name that caused this error
-
-
Method Details
-
toMap
Convert this instance to a map.- Returns:
- an unmodifiable map
- See Also:
-
toString
-
valueOf
Build anErrorMessagefrom the given map of properties, whose keys must correspond to the property names and whose values must have the expected type.- Parameters:
props- error message properties- Returns:
- a new ErrorMessage
-
getCode
public int getCode() -
getFieldName
-
getItemId
-
getMessage
-
equals
-
canEqual
-
hashCode
public int hashCode()
-