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, org.springframework.web.ErrorResponse.Interceptor
  • Constructor Summary

    Constructors
    Constructor
    Description
    ResponseStatusException2(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 Type
    Method
    Description
    Returns something like: "User not found (HTTP 404 NOT_FOUND)" The first part is ResponseStatusException.getReason(), if null, it tries to get HttpStatus.getReasonPhrase() from
    invalid reference
    #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.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

      public ResponseStatusException2(org.springframework.http.HttpStatus status, String reason)
    • ResponseStatusException2

      public ResponseStatusException2(org.springframework.http.HttpStatus status, String reason, Throwable cause)
    • ResponseStatusException2

      public ResponseStatusException2(int rawStatusCode, String reason, Throwable cause)
  • Method Details

    • getMessage

      public String getMessage()
      Returns something like: "User not found (HTTP 404 NOT_FOUND)" The first part is ResponseStatusException.getReason(), if null, it tries to get HttpStatus.getReasonPhrase() from
      invalid reference
      #getStatus()
      , if this is null too, the second part only is reported without any braces. If
      invalid reference
      #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 class org.springframework.web.server.ResponseStatusException