- java.lang.Object
-
- java.lang.Enum<HttpExceptionHandling>
-
- org.refcodes.rest.HttpExceptionHandling
-
- All Implemented Interfaces:
Serializable
,Comparable<HttpExceptionHandling>
public enum HttpExceptionHandling extends Enum<HttpExceptionHandling>
Defines how errors affect the HTTP-Body whilst processing aHttpRequest
or aHttpResponse
along with the according sub-classes. Usually the following fields are written into the HTTP-Body (if possible): "timestamp", "status", "error": "Bad Request", "exception" and "message". Usually the causing exception's message is used for the "message" attribute: Make sure you do not reveal any sensible information in the exception's message.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description EMPTY
Create a new HTTP-Response with the according HTTP-Status-Code and and an empty body.KEEP
Do not modify the so far processed HTTP-Response except update the actual HTTP-Status-Code.MERGE
Keep the so far processed HTTP-Response as is except update the actual HTTP-Status-Code, add only non-existing fields if possible with the error description fields.REPLACE
Create a new HTTP-Response with the according HTTP-Status-Code and the error description fields.UPDATE
Keep the so far processed HTTP-Response as is except the HTTP-Status-Code and also update all error description fields.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static HttpExceptionHandling
valueOf(String name)
Returns the enum constant of this type with the specified name.static HttpExceptionHandling[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
KEEP
public static final HttpExceptionHandling KEEP
Do not modify the so far processed HTTP-Response except update the actual HTTP-Status-Code. Useful when you manually prepared the HTTP-Response yourself.
-
MERGE
public static final HttpExceptionHandling MERGE
Keep the so far processed HTTP-Response as is except update the actual HTTP-Status-Code, add only non-existing fields if possible with the error description fields. Useful when you manually prepared the HTTP-Response yourself.
-
UPDATE
public static final HttpExceptionHandling UPDATE
Keep the so far processed HTTP-Response as is except the HTTP-Status-Code and also update all error description fields. Useful when you want to preserve already set fields.
-
REPLACE
public static final HttpExceptionHandling REPLACE
Create a new HTTP-Response with the according HTTP-Status-Code and the error description fields.
-
EMPTY
public static final HttpExceptionHandling EMPTY
Create a new HTTP-Response with the according HTTP-Status-Code and and an empty body.
-
-
Method Detail
-
values
public static HttpExceptionHandling[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (HttpExceptionHandling c : HttpExceptionHandling.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static HttpExceptionHandling valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified nameNullPointerException
- if the argument is null
-
-