public class HttpResponseException extends ContrastException
Typically, HTTP status codes in the 4XX and 5XX ranges indicate an error; however, in some legacy cases, the Contrast API may return a successful status code (e.g. 200) with an error body. In this case, the Contrast Java SDK still throws this exception.
| Constructor and Description |
|---|
HttpResponseException(java.lang.String message,
java.lang.String method,
java.lang.String path,
int code,
java.lang.String status)
Constructor.
|
HttpResponseException(java.lang.String message,
java.lang.String method,
java.lang.String path,
int code,
java.lang.String status,
java.lang.String body)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
static HttpResponseException |
fromConnection(java.net.HttpURLConnection connection,
java.lang.String message)
Static factory method that captures the status line and body of the given
HttpURLConnection to create a new exception. |
java.lang.String |
getBody() |
int |
getCode() |
java.lang.String |
getMessage() |
java.lang.String |
getStatus() |
public HttpResponseException(java.lang.String message,
java.lang.String method,
java.lang.String path,
int code,
java.lang.String status)
message - error message provided by the callermethod - HTTP method used in the requestpath - HTTP path from the requestcode - code from the status line e.g. 400status - message from the status line e.g. Bad Requestpublic HttpResponseException(java.lang.String message,
java.lang.String method,
java.lang.String path,
int code,
java.lang.String status,
java.lang.String body)
message - error message provided by the callermethod - HTTP method used in the requestpath - HTTP path from the requestcode - code from the status line e.g. 400status - message from the status line e.g. Bad Requestbody - the body of the response, or null if there is no such bodyjava.lang.NullPointerException - when message, method, or path are nullpublic static HttpResponseException fromConnection(java.net.HttpURLConnection connection, java.lang.String message) throws java.io.IOException
HttpURLConnection to create a new exception.connection - connection from which to derive status line and body informationmessage - error message provided by the callerHttpResponseExceptionjava.io.IOException - when fails to read the status line or body of the responsepublic int getCode()
public java.lang.String getStatus()
null if no such status line
existspublic java.lang.String getBody()
null if there is no such bodypublic java.lang.String getMessage()
getMessage in class java.lang.ThrowableCopyright © 2022 Contrast Security, Inc.. All rights reserved.