Class ApiException

java.lang.Object
java.lang.Throwable
java.lang.Exception
pro.nikolaev.restutils.exceptions.ApiException
All Implemented Interfaces:
Serializable

public class ApiException extends Exception
Exception intended to use to expose an HTTP status and reason to @ExceptionHandler.
Since:
1.0
Author:
Ilya Nikolaev
See Also:
  • Constructor Details

    • ApiException

      public ApiException(org.springframework.http.HttpStatusCode status, String reason)
      Constructor with a response status and a reason.
      Parameters:
      status - the HTTP status
      reason - the associated reason
      Since:
      1.0
    • ApiException

      public ApiException(org.springframework.http.HttpStatusCode status, String reason, String message)
      Constructor with a response status, reason and message as explanation.
      Parameters:
      status - the HTTP status
      reason - the associated reason
      message - the explanation of an error or a hint on how to avoid it
      Since:
      1.0
    • ApiException

      public ApiException(org.springframework.http.HttpStatusCode status, String reason, String message, Throwable cause)
      Constructor with a response status, reason and message as explanation, as well as a nested exception.
      Parameters:
      status - the HTTP status
      reason - the associated reason
      message - the explanation of an error or a hint on how to avoid it
      cause - a nested exception (optional)
      Since:
      1.0
    • ApiException

      public ApiException(org.springframework.http.HttpStatusCode status, String reason, Throwable cause)
      Constructor with a response status and reason as well as a nested exception.
      Parameters:
      status - the HTTP status
      reason - the associated reason
      cause - a nested exception (optional)
      Since:
      1.0
    • ApiException

      public ApiException(org.springframework.http.HttpStatusCode status, String reason, String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace)
      Constructor with a response status, reason and message as explanation, as well as a nested exception, suppression enabled or disabled, and writable stack trace enabled or disabled.
      Parameters:
      status - the HTTP status
      reason - the associated reason
      message - the explanation of an error or a hint on how to avoid it
      cause - a nested exception (optional)
      enableSuppression - whether suppression is enabled or disable
      writableStackTrace - whether the stack trace should be writable
      Since:
      1.0
  • Method Details

    • getStatus

      public org.springframework.http.HttpStatusCode getStatus()
      Return the HTTP status code to use for the response.
    • getReason

      public String getReason()
      The reason explaining the exception (potentially null or empty).