Class BasicHttpException
- All Implemented Interfaces:
- Serializable,- HttpMessage,- HttpResponse
- Direct Known Subclasses:
- BadRequest,- Conflict,- ExpectationFailed,- FailedDependency,- Forbidden,- Gone,- HttpVersionNotSupported,- InsufficientStorage,- InternalServerError,- LengthRequired,- Locked,- LoopDetected,- MethodNotAllowed,- MisdirectedRequest,- NetworkAuthenticationRequired,- NotAcceptable,- NotExtended,- NotFound,- NotImplemented,- PayloadTooLarge,- PreconditionFailed,- PreconditionRequired,- RangeNotSatisfiable,- RequestHeaderFieldsTooLarge,- ServiceUnavailable,- TooManyRequests,- Unauthorized,- UnavailableForLegalReasons,- UnprocessableEntity,- UnsupportedMediaType,- UpgradeRequired,- UriTooLong,- VariantAlsoNegotiates
HttpResponse interface for error responses.
 
 Although this class implements the various setters defined on the HttpResponse interface, it's in general
 going to be more efficient to set the status/headers/content of this bean through the builder.
 
 If the UnsupportedOperationException exceptions.
 
Notes:
- Beans are not thread safe unless they're marked as unmodifiable.
See Also:
- 
Constructor SummaryConstructorsModifierConstructorDescriptionConstructor.BasicHttpException(int statusCode) Constructor.BasicHttpException(int statusCode, String msg, Object... args) Constructor.BasicHttpException(int statusCode, Throwable causedBy) Constructor.BasicHttpException(int statusCode, Throwable cause, String msg, Object... args) Constructor.BasicHttpException(HttpResponse response) Constructor.protectedBasicHttpException(BasicHttpException copyFrom) Copy constructor.
- 
Method SummaryModifier and TypeMethodDescriptionvoidvoidprotected voidassertStatusCode(HttpResponse response) Asserts that the specified HTTP response has the same status code as the one on the status line of this bean.booleancontainsHeader(String name) Header[]getFirstHeader(String name) getFullStackMessage(boolean scrubForXssVulnerabilities) Returns all error messages from all errors in this stack.Returns access to the underlying builder for the headers.Header[]getHeaders(String name) getLastHeader(String name) Returns the root cause of this exception.inthashCode()headerIterator(String name) voidremoveHeader(Header value) voidremoveHeaders(String name) setContent(String value) Sets the body on this response.setContent(HttpEntity value) Sets the body on this response.voidsetEntity(HttpEntity entity) voidvoidsetHeader2(String name, Object value) Sets a header on this response.setHeaders(List<Header> values) Sets the specified headers on this response.voidsetHeaders(Header[] values) setHeaders(HeaderList value) Sets the specified headers on this response.setHeaders2(Header... values) Sets multiple headers on this response.voidsetLocale2(Locale value) Sets the locale used to retrieve reason phrases.setMessage(String message, Object... args) Sets the detail message on this exception.voidsetParams(HttpParams params) Sets the protocol version on the status line.voidsetReasonPhrase(String reason) setReasonPhrase2(String value) Sets the reason phrase on the status line.Sets the reason phrase catalog used to retrieve reason phrases.voidsetStatusCode(int code) setStatusCode2(int code) Same assetStatusCode(int)but returns this object.voidsetStatusLine(ProtocolVersion ver, int code) voidsetStatusLine(ProtocolVersion ver, int code, String reason) voidsetStatusLine(StatusLine value) setStatusLine(BasicStatusLine value) Sets the protocol version on the status line.Specifies whether this bean should be unmodifiable.toString()Methods inherited from class org.apache.juneau.BasicRuntimeExceptionassertModifiable, fillInStackTrace, getCause, initCause, isUnmodifiable, setStackTrace, unwrapMethods inherited from class java.lang.ThrowableaddSuppressed, getCause, getLocalizedMessage, getStackTrace, getSuppressed, printStackTrace, printStackTrace, printStackTrace
- 
Constructor Details- 
BasicHttpExceptionConstructor.- Parameters:
- statusCode- The HTTP status code.
- cause- The caused-by exception. Can be- null .
- msg- The message. Can be- null .
- args- The message arguments.
 
- 
BasicHttpExceptionConstructor.- Parameters:
- statusCode- The HTTP status code.
 
- 
BasicHttpExceptionConstructor.- Parameters:
- statusCode- The HTTP status code.
- msg- The message. Can be- null .
- args- Optional- MessageFormat-style arguments in the message.
 
- 
BasicHttpExceptionConstructor.- Parameters:
- statusCode- The HTTP status code.
- causedBy- The cause. Can be- null .
 
- 
BasicHttpExceptionpublic BasicHttpException()Constructor.
- 
BasicHttpExceptionConstructor.This is the constructor used when parsing an HTTP response. - Parameters:
- response- The HTTP response being parsed.
 
- 
BasicHttpExceptionCopy constructor.- Parameters:
- copyFrom- The bean to copy.
 
 
- 
- 
Method Details- 
setUnmodifiableSpecifies whether this bean should be unmodifiable.When enabled, attempting to set any properties on this bean will cause an UnsupportedOperationException.- Overrides:
- setUnmodifiablein class- BasicRuntimeException
- Returns:
- This object.
 
- 
setStatusLineSets the protocol version on the status line.If not specified, "HTTP/1.1" will be used.- Parameters:
- value- The new value.
- Returns:
- This object.
 
- 
setStatusCode2Same assetStatusCode(int)but returns this object.- Parameters:
- code- The new status code.
- Returns:
- This object.
- Throws:
- IllegalStateException- If status code could not be set.
 
- 
setProtocolVersionSets the protocol version on the status line.If not specified, "HTTP/1.1" will be used.- Parameters:
- value- The new value.
- Returns:
- This object.
 
- 
setReasonPhrase2Sets the reason phrase on the status line.If not specified, the reason phrase will be retrieved from the reason phrase catalog using the locale on this builder. - Parameters:
- value- The new value.
- Returns:
- This object.
 
- 
setReasonPhraseCatalogSets the reason phrase catalog used to retrieve reason phrases.If not specified, uses EnglishReasonPhraseCatalog.- Parameters:
- value- The new value.
- Returns:
- This object.
 
- 
setLocale2Sets the locale used to retrieve reason phrases.If not specified, uses Locale.getDefault().- Parameters:
- value- The new value.
- Returns:
- This object.
 
- 
getHeadersReturns access to the underlying builder for the headers.- Returns:
- The underlying builder for the headers.
 
- 
setHeadersSets the specified headers on this response.- Parameters:
- value- The new value.
- Returns:
- This object.
 
- 
setHeader2Sets a header on this response.- Parameters:
- name- The header name.
- value- The header value.
- Returns:
- This object.
 
- 
setHeaders2Sets multiple headers on this response.- Parameters:
- values- The headers to add.
- Returns:
- This object.
 
- 
setHeadersSets the specified headers on this response.- Parameters:
- values- The headers to set.- null values are ignored.
- Returns:
- This object.
 
- 
setContentSets the body on this response.- Parameters:
- value- The body on this response.
- Returns:
- This object.
 
- 
setContentSets the body on this response.- Parameters:
- value- The body on this response.
- Returns:
- This object.
 
- 
assertStatusCodeAsserts that the specified HTTP response has the same status code as the one on the status line of this bean.- Parameters:
- response- The HTTP response to check. Must not be- null .
- Throws:
- AssertionError- If status code is not what was expected.
 
- 
getRootCauseReturns the root cause of this exception.The root cause is the first exception in the init-cause parent chain that's not one of the following: - Returns:
- The root cause of this exception, or null if no root cause was found.
 
- 
getFullStackMessageReturns all error messages from all errors in this stack.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. - Parameters:
- scrubForXssVulnerabilities- If- true , replaces- '<' ,- '>' , and- '&' characters with spaces.
- Returns:
- All error messages from all errors in this stack.
 
- 
getMessage- Overrides:
- getMessagein class- BasicRuntimeException
 
- 
hashCode
- 
toString
- 
getProtocolVersion- Specified by:
- getProtocolVersionin interface- HttpMessage
 
- 
containsHeader- Specified by:
- containsHeaderin interface- HttpMessage
 
- 
getHeaders- Specified by:
- getHeadersin interface- HttpMessage
 
- 
getFirstHeader- Specified by:
- getFirstHeaderin interface- HttpMessage
 
- 
getLastHeader- Specified by:
- getLastHeaderin interface- HttpMessage
 
- 
getAllHeaders- Specified by:
- getAllHeadersin interface- HttpMessage
 
- 
addHeader- Specified by:
- addHeaderin interface- HttpMessage
 
- 
addHeader- Specified by:
- addHeaderin interface- HttpMessage
 
- 
setHeader- Specified by:
- setHeaderin interface- HttpMessage
 
- 
setHeader- Specified by:
- setHeaderin interface- HttpMessage
 
- 
setHeaders- Specified by:
- setHeadersin interface- HttpMessage
 
- 
removeHeader- Specified by:
- removeHeaderin interface- HttpMessage
 
- 
removeHeaders- Specified by:
- removeHeadersin interface- HttpMessage
 
- 
headerIterator- Specified by:
- headerIteratorin interface- HttpMessage
 
- 
headerIterator- Specified by:
- headerIteratorin interface- HttpMessage
 
- 
getParams- Specified by:
- getParamsin interface- HttpMessage
 
- 
setParams- Specified by:
- setParamsin interface- HttpMessage
 
- 
getStatusLine- Specified by:
- getStatusLinein interface- HttpResponse
 
- 
setStatusLine- Specified by:
- setStatusLinein interface- HttpResponse
 
- 
setStatusLine- Specified by:
- setStatusLinein interface- HttpResponse
 
- 
setStatusLine- Specified by:
- setStatusLinein interface- HttpResponse
 
- 
setStatusCode- Specified by:
- setStatusCodein interface- HttpResponse
- Throws:
- IllegalStateException
 
- 
setReasonPhrase- Specified by:
- setReasonPhrasein interface- HttpResponse
- Throws:
- IllegalStateException
 
- 
getEntity- Specified by:
- getEntityin interface- HttpResponse
 
- 
setEntity- Specified by:
- setEntityin interface- HttpResponse
 
- 
getLocale- Specified by:
- getLocalein interface- HttpResponse
 
- 
setLocale- Specified by:
- setLocalein interface- HttpResponse
 
- 
setMessageDescription copied from class:BasicRuntimeExceptionSets the detail message on this exception.- Overrides:
- setMessagein class- BasicRuntimeException
- Parameters:
- message- The message.
- args- The message args.
- Returns:
- This object.
 
 
-