Class ResponseStatusException2
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.springframework.core.NestedRuntimeException
org.springframework.web.ErrorResponseException
org.springframework.web.server.ResponseStatusException
uk.ac.ebi.utils.opt.springweb.exceptions.ResponseStatusException2
- All Implemented Interfaces:
Serializable
,org.springframework.web.ErrorResponse
public class ResponseStatusException2
extends org.springframework.web.server.ResponseStatusException
An alternative version of
ResponseStatusException
that yields a more compact and better-formatted
getMessage()
. Throw this in place of ResponseStatusException
if you prefer our flavour of it.- Author:
- brandizi
- Date:
- 9 Jun 2021
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.web.ErrorResponse
org.springframework.web.ErrorResponse.Builder
-
Constructor Summary
ConstructorDescriptionResponseStatusException2
(int rawStatusCode, String reason, Throwable cause) ResponseStatusException2
(org.springframework.http.HttpStatus status) ResponseStatusException2
(org.springframework.http.HttpStatus status, String reason) ResponseStatusException2
(org.springframework.http.HttpStatus status, String reason, Throwable cause) -
Method Summary
Modifier and TypeMethodDescriptionReturns something like: "User not found (HTTP 404 NOT_FOUND)" The first part isResponseStatusException.getReason()
, if null, it tries to getHttpStatus.getReasonPhrase()
from#getStatus()
, if this is null too, the second part only is reported without any braces.Methods inherited from class org.springframework.web.server.ResponseStatusException
getHeaders, getReason, getResponseHeaders, updateAndGetBody
Methods inherited from class org.springframework.web.ErrorResponseException
getBody, getDetailMessageArguments, getDetailMessageCode, getStatusCode, setDetail, setInstance, setTitle, setType
Methods inherited from class org.springframework.core.NestedRuntimeException
contains, getMostSpecificCause, getRootCause
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.web.ErrorResponse
getDetailMessageArguments, getTitleMessageCode, getTypeMessageCode
-
Constructor Details
-
ResponseStatusException2
public ResponseStatusException2(org.springframework.http.HttpStatus status) -
ResponseStatusException2
-
ResponseStatusException2
-
ResponseStatusException2
-
-
Method Details
-
getMessage
Returns something like: "User not found (HTTP 404 NOT_FOUND)" The first part isResponseStatusException.getReason()
, if null, it tries to getHttpStatus.getReasonPhrase()
from#getStatus()
, if this is null too, the second part only is reported without any braces. If#getRawStatusCode()
only is available, the second part reports the int code only. This version of the message getter doesn't yield the cause's message and this is up to you to pass it in the constructor.- Overrides:
getMessage
in classorg.springframework.web.server.ResponseStatusException
-