public class RestException extends RuntimeException
REST methods on subclasses of RestServlet
can throw this exception to trigger an HTTP status other than the
automatically-generated 404
, 405
, and 500
statuses.
Constructor and Description |
---|
RestException(int status,
String msg,
Object... args)
Constructor.
|
RestException(int status,
Throwable cause)
Deprecated.
|
RestException(String msg)
Constructor.
|
RestException(Throwable cause,
int status)
Constructor.
|
RestException(Throwable cause,
int status,
String msg,
Object... args)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
String |
getFullStackMessage(boolean scrubForXssVulnerabilities)
Returns all error messages from all errors in this stack.
|
int |
getOccurrence()
Returns the number of times this exception occurred on this servlet.
|
Throwable |
getRootCause()
Returns the root cause of this exception.
|
int |
getStatus()
Returns the HTTP status code.
|
int |
hashCode() |
RestException |
initCause(Throwable cause)
Deprecated.
|
protected RestException |
setOccurrence(int occurrence)
Set the occurrence count on this exception.
|
protected RestException |
setStatus(int status)
Set the status code on this exception.
|
String |
toString() |
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, printStackTrace, printStackTrace, printStackTrace, setStackTrace
public RestException(Throwable cause, int status, String msg, Object... args)
cause
- The cause of this exception.status
- The HTTP status code.msg
- The status message.args
- Optional MessageFormat
-style arguments.public RestException(String msg)
msg
- The status message.public RestException(Throwable cause, int status)
cause
- The root exception.status
- The HTTP status code.public RestException(int status, String msg, Object... args)
status
- The HTTP status code.msg
- The status message.args
- Optional MessageFormat
-style arguments.@Deprecated public RestException(int status, Throwable cause)
public Throwable getRootCause()
The root cause is the first exception in the init-cause parent chain that's not one of the following:
public String getFullStackMessage(boolean scrubForXssVulnerabilities)
Typically useful if you want to render all the error messages in the stack, but don't want to render all the stack traces too.
scrubForXssVulnerabilities
- If protected RestException setOccurrence(int occurrence)
occurrence
- The number of times this exception has occurred.protected RestException setStatus(int status)
status
- The status code.public int getOccurrence()
@RestResource(useStackTraceHashes)
is enabled, or 0
otherwise.public int getStatus()
@Deprecated public RestException initCause(Throwable cause)
Copyright © 2018 Apache. All rights reserved.