Top Description Fields Constructors Methods
jakarta.ws.rs

public Class WebApplicationException

extends RuntimeException
Class Inheritance
Known Direct Subclasses
jakarta.ws.rs.ClientErrorException, jakarta.ws.rs.RedirectionException, jakarta.ws.rs.ServerErrorException
Imports
jakarta.ws.rs.core.Response

Runtime exception for applications.

This exception may be thrown by a resource method, provider or jakarta.ws.rs.core.StreamingOutput implementation if a specific HTTP error response needs to be produced. Only effective if thrown prior to the response being committed.

Authors
Paul Sandoz, Marek Potociar
Since
1.0

Field Summary

Modifier and TypeField and Description
private final transient Response
private static final long

Constructor Summary

AccessConstructor and Description
public
WebApplicationException()

Construct a new instance with a default HTTP status code of 500 and a default message generated from the HTTP status code and the associated HTTP status reason phrase.

public
WebApplicationException(final String
the detail message (which is saved for later retrieval by the getMessage() method).
message
)

Construct a new instance with the supplied message and a default HTTP status code of 500.

public
WebApplicationException(final Response
the response that will be returned to the client, a value of null will be replaced with an internal server error response (status code 500).
response
)

Construct a new instance using the supplied response and a default message generated from the response's HTTP status code and the associated HTTP status reason phrase.

public
WebApplicationException(final String
the detail message (which is saved for later retrieval by the getMessage() method).
message
,
final Response
the response that will be returned to the client, a value of null will be replaced with an internal server error response (status code 500).
response
)

Construct a new instance using the supplied message and response.

public
WebApplicationException(final int
the HTTP status code that will be returned to the client.
status
)

Construct a new instance with the supplied HTTP status code and a default message generated from the HTTP status code and the associated HTTP status reason phrase.

public
WebApplicationException(final String
the detail message (which is saved for later retrieval by the getMessage() method).
message
,
final int
the HTTP status code that will be returned to the client.
status
)

Construct a new instance with a supplied message and HTTP status code.

public
WebApplicationException(final Response.Status
the HTTP status code that will be returned to the client.
status
)

Construct a new instance with the supplied HTTP status and a default message generated from the HTTP status code and the associated HTTP status reason phrase.

public
WebApplicationException(final String
the detail message (which is saved for later retrieval by the getMessage() method).
message
,
final Response.Status
the HTTP status code that will be returned to the client.
status
)

Construct a new instance with the supplied message and HTTP status.

public
WebApplicationException(final Throwable
the underlying cause of the exception.
cause
)

Construct a new instance with the supplied root cause, default HTTP status code of 500 and a default message generated from the HTTP status code and the associated HTTP status reason phrase.

public
WebApplicationException(final String
the detail message (which is saved for later retrieval by the getMessage() method).
message
,
final Throwable
the underlying cause of the exception.
cause
)

Construct a new instance with the supplied message, root cause and default HTTP status code of 500.

public
WebApplicationException(final Throwable
the underlying cause of the exception.
cause
,
final Response
the response that will be returned to the client, a value of null will be replaced with an internal server error response (status code 500).
response
)

Construct a new instance with the supplied root cause, response and a default message generated from the response's HTTP status code and the associated HTTP status reason phrase.

public
WebApplicationException(final String
the detail message (which is saved for later retrieval by the getMessage() method).
message
,
final Throwable
the underlying cause of the exception.
cause
,
final Response
the response that will be returned to the client, a value of null will be replaced with an internal server error response (status code 500).
response
)

Construct a new instance with the supplied message, root cause and response.

public
WebApplicationException(final Throwable
the underlying cause of the exception.
cause
,
final int
the HTTP status code that will be returned to the client.
status
)

Construct a new instance with the supplied root cause, HTTP status code and a default message generated from the HTTP status code and the associated HTTP status reason phrase.

public
WebApplicationException(final String
the detail message (which is saved for later retrieval by the getMessage() method).
message
,
final Throwable
the underlying cause of the exception.
cause
,
final int
the HTTP status code that will be returned to the client.
status
)

Construct a new instance with the supplied message, root cause and HTTP status code.

public
WebApplicationException(final Throwable
the underlying cause of the exception.
cause
,
final Response.Status
the HTTP status code that will be returned to the client.
status
)

Construct a new instance with the supplied root cause, HTTP status code and a default message generated from the HTTP status code and the associated HTTP status reason phrase.

public
WebApplicationException(final String
the detail message (which is saved for later retrieval by the getMessage() method).
message
,
final Throwable
the underlying cause of the exception.
cause
,
final Response.Status
the HTTP status code that will be returned to the client.
status
)

Construct a new instance with a the supplied message, root cause and HTTP status code.

Method Summary

Modifier and TypeMethod and Description
private static String
public Response

Returns:

the HTTP response.
getResponse
()

Get the HTTP response.

pack-priv static Response

Returns:

validated response object.
validate
(final Response
response object.
response
,
final Response.Status
expected response status code.
expectedStatus
)

Validate that a jakarta.ws.rs.core.Response object has an expected HTTP response status code set.

pack-priv static Response

Returns:

validated response object.
validate
(final Response
response object.
response
,
final Response.Status.Family
expected response status code family.
expectedStatusFamily
)

Validate that a jakarta.ws.rs.core.Response object has an expected HTTP response status code set.

Field Detail

responseback to summary
private final transient Response response
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.RuntimeException.serialVersionUID.

Constructor Detail

WebApplicationExceptionback to summary
public WebApplicationException()

Construct a new instance with a default HTTP status code of 500 and a default message generated from the HTTP status code and the associated HTTP status reason phrase.

WebApplicationExceptionback to summary
public WebApplicationException(final String message)

Construct a new instance with the supplied message and a default HTTP status code of 500.

Parameters
message:String

the detail message (which is saved for later retrieval by the getMessage() method).

Since
2.0
WebApplicationExceptionback to summary
public WebApplicationException(final Response response)

Construct a new instance using the supplied response and a default message generated from the response's HTTP status code and the associated HTTP status reason phrase.

Parameters
response:Response

the response that will be returned to the client, a value of null will be replaced with an internal server error response (status code 500).

WebApplicationExceptionback to summary
public WebApplicationException(final String message, final Response response)

Construct a new instance using the supplied message and response.

Parameters
message:String

the detail message (which is saved for later retrieval by the getMessage() method).

response:Response

the response that will be returned to the client, a value of null will be replaced with an internal server error response (status code 500).

Since
2.0
WebApplicationExceptionback to summary
public WebApplicationException(final int status)

Construct a new instance with the supplied HTTP status code and a default message generated from the HTTP status code and the associated HTTP status reason phrase.

Parameters
status:int

the HTTP status code that will be returned to the client.

WebApplicationExceptionback to summary
public WebApplicationException(final String message, final int status)

Construct a new instance with a supplied message and HTTP status code.

Parameters
message:String

the detail message (which is saved for later retrieval by the getMessage() method).

status:int

the HTTP status code that will be returned to the client.

Since
2.0
WebApplicationExceptionback to summary
public WebApplicationException(final Response.Status status)

Construct a new instance with the supplied HTTP status and a default message generated from the HTTP status code and the associated HTTP status reason phrase.

Parameters
status:Response.Status

the HTTP status code that will be returned to the client.

Exceptions
IllegalArgumentException:
if status is null.
WebApplicationExceptionback to summary
public WebApplicationException(final String message, final Response.Status status)

Construct a new instance with the supplied message and HTTP status.

Parameters
message:String

the detail message (which is saved for later retrieval by the getMessage() method).

status:Response.Status

the HTTP status code that will be returned to the client.

Exceptions
IllegalArgumentException:
if status is null.
Since
2.0
WebApplicationExceptionback to summary
public WebApplicationException(final Throwable cause)

Construct a new instance with the supplied root cause, default HTTP status code of 500 and a default message generated from the HTTP status code and the associated HTTP status reason phrase.

Parameters
cause:Throwable

the underlying cause of the exception.

WebApplicationExceptionback to summary
public WebApplicationException(final String message, final Throwable cause)

Construct a new instance with the supplied message, root cause and default HTTP status code of 500.

Parameters
message:String

the detail message (which is saved for later retrieval by the getMessage() method).

cause:Throwable

the underlying cause of the exception.

Since
2.0
WebApplicationExceptionback to summary
public WebApplicationException(final Throwable cause, final Response response)

Construct a new instance with the supplied root cause, response and a default message generated from the response's HTTP status code and the associated HTTP status reason phrase.

Parameters
cause:Throwable

the underlying cause of the exception.

response:Response

the response that will be returned to the client, a value of null will be replaced with an internal server error response (status code 500).

WebApplicationExceptionback to summary
public WebApplicationException(final String message, final Throwable cause, final Response response)

Construct a new instance with the supplied message, root cause and response.

Parameters
message:String

the detail message (which is saved for later retrieval by the getMessage() method).

cause:Throwable

the underlying cause of the exception.

response:Response

the response that will be returned to the client, a value of null will be replaced with an internal server error response (status code 500).

Since
2.0
WebApplicationExceptionback to summary
public WebApplicationException(final Throwable cause, final int status)

Construct a new instance with the supplied root cause, HTTP status code and a default message generated from the HTTP status code and the associated HTTP status reason phrase.

Parameters
cause:Throwable

the underlying cause of the exception.

status:int

the HTTP status code that will be returned to the client.

WebApplicationExceptionback to summary
public WebApplicationException(final String message, final Throwable cause, final int status)

Construct a new instance with the supplied message, root cause and HTTP status code.

Parameters
message:String

the detail message (which is saved for later retrieval by the getMessage() method).

cause:Throwable

the underlying cause of the exception.

status:int

the HTTP status code that will be returned to the client.

Since
2.0
WebApplicationExceptionback to summary
public WebApplicationException(final Throwable cause, final Response.Status status) throws IllegalArgumentException

Construct a new instance with the supplied root cause, HTTP status code and a default message generated from the HTTP status code and the associated HTTP status reason phrase.

Parameters
cause:Throwable

the underlying cause of the exception.

status:Response.Status

the HTTP status code that will be returned to the client.

Exceptions
IllegalArgumentException:
if status is null.
WebApplicationExceptionback to summary
public WebApplicationException(final String message, final Throwable cause, final Response.Status status) throws IllegalArgumentException

Construct a new instance with a the supplied message, root cause and HTTP status code.

Parameters
message:String

the detail message (which is saved for later retrieval by the getMessage() method).

cause:Throwable

the underlying cause of the exception.

status:Response.Status

the HTTP status code that will be returned to the client.

Exceptions
IllegalArgumentException:
if status is null.
Since
2.0

Method Detail

computeExceptionMessageback to summary
private static String computeExceptionMessage(final Response response)
getResponseback to summary
public Response getResponse()

Get the HTTP response.

Returns:Response

the HTTP response.

validateback to summary
pack-priv static Response validate(final Response response, final Response.Status expectedStatus)

Validate that a jakarta.ws.rs.core.Response object has an expected HTTP response status code set.

Parameters
response:Response

response object.

expectedStatus:Response.Status

expected response status code.

Returns:Response

validated response object.

Exceptions
IllegalArgumentException:
if the response validation failed.
Since
2.0
validateback to summary
pack-priv static Response validate(final Response response, final Response.Status.Family expectedStatusFamily)

Validate that a jakarta.ws.rs.core.Response object has an expected HTTP response status code set.

Parameters
response:Response

response object.

expectedStatusFamily:Response.Status.Family

expected response status code family.

Returns:Response

validated response object.

Exceptions
IllegalArgumentException:
if the response validation failed.
Since
2.0