Class ApiException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
pro.nikolaev.restutils.exceptions.ApiException
- All Implemented Interfaces:
Serializable
RuntimeException intended to use to expose an HTTP status and reason
to @ExceptionHandler.- Since:
- 1.0
- Author:
- Ilya Nikolaev
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionApiException(org.springframework.http.HttpStatusCode status, String reason) Constructor with a response status and a reason.ApiException(org.springframework.http.HttpStatusCode status, String reason, String message) Constructor with a response status, reason and message as explanation.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.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.ApiException(org.springframework.http.HttpStatusCode status, String reason, Throwable cause) Constructor with a response status and reason as well as a nested exception. -
Method Summary
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
ApiException
Constructor with a response status and a reason.- Parameters:
status- the HTTP statusreason- the associated reason- Since:
- 1.0
-
ApiException
Constructor with a response status, reason and message as explanation.- Parameters:
status- the HTTP statusreason- the associated reasonmessage- 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 statusreason- the associated reasonmessage- the explanation of an error or a hint on how to avoid itcause- a nested exception (optional)- Since:
- 1.0
-
ApiException
Constructor with a response status and reason as well as a nested exception.- Parameters:
status- the HTTP statusreason- the associated reasoncause- 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 statusreason- the associated reasonmessage- the explanation of an error or a hint on how to avoid itcause- a nested exception (optional)enableSuppression- whether suppression is enabled or disablewritableStackTrace- 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
The reason explaining the exception (potentiallynullor empty).
-