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:
  • 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 #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 class org.springframework.web.server.ResponseStatusException