@Private
@Unstable
public class HttpExceptionUtils
extends java.lang.Object
It creates HTTP Servlet and JAX-RPC error responses including details of the exception that allows a client to recreate the remote exception.
It parses HTTP client connections and recreates the exception.
| Modifier and Type | Field | Description |
|---|---|---|
static java.lang.String |
ERROR_CLASSNAME_JSON |
|
static java.lang.String |
ERROR_EXCEPTION_JSON |
|
static java.lang.String |
ERROR_JSON |
|
static java.lang.String |
ERROR_MESSAGE_JSON |
| Constructor | Description |
|---|---|
HttpExceptionUtils() |
| Modifier and Type | Method | Description |
|---|---|---|
static javax.ws.rs.core.Response |
createJerseyExceptionResponse(javax.ws.rs.core.Response.Status status,
java.lang.Throwable ex) |
Creates a HTTP JAX-RPC response serializing the exception in it as JSON.
|
static void |
createServletExceptionResponse(javax.servlet.http.HttpServletResponse response,
int status,
java.lang.Throwable ex) |
Creates a HTTP servlet response serializing the exception in it as JSON.
|
static void |
validateResponse(java.net.HttpURLConnection conn,
int expectedStatus) |
Validates the status of an
HttpURLConnection against an
expected HTTP status code. |
public static final java.lang.String ERROR_JSON
public static final java.lang.String ERROR_EXCEPTION_JSON
public static final java.lang.String ERROR_CLASSNAME_JSON
public static final java.lang.String ERROR_MESSAGE_JSON
public static void createServletExceptionResponse(javax.servlet.http.HttpServletResponse response,
int status,
java.lang.Throwable ex)
throws java.io.IOException
response - the servlet responsestatus - the error code to set in the responseex - the exception to serialize in the responsejava.io.IOException - thrown if there was an error while creating the
responsepublic static javax.ws.rs.core.Response createJerseyExceptionResponse(javax.ws.rs.core.Response.Status status,
java.lang.Throwable ex)
status - the error code to set in the responseex - the exception to serialize in the responsepublic static void validateResponse(java.net.HttpURLConnection conn,
int expectedStatus)
throws java.io.IOException
HttpURLConnection against an
expected HTTP status code. If the current status code is not the expected
one it throws an exception with a detail message using Server side error
messages if available.
NOTE: this method will throw the deserialized exception even if not
declared in the throws of the method signature.
conn - the HttpURLConnection.expectedStatus - the expected HTTP status code.java.io.IOException - thrown if the current status code does not match the
expected one.Copyright © 2008–2025 Apache Software Foundation. All rights reserved.