Package net.officefloor.server.http
Class HttpException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.RuntimeException
-
- net.officefloor.server.http.HttpException
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
AccessTokenException
,AuthenticationContinuationException
,BadRequestHttpException
,InvalidatedSessionHttpException
,NotFoundHttpException
,RefreshTokenException
,RetrieveValueException
,StoringSessionHttpException
,ValidateKeysException
public class HttpException extends java.lang.RuntimeException
HTTP
Exception
.This is a
RuntimeException
as typically this is handled directly by theHttpServerImplementation
to send aHttpResponse
. It is typically not for application logic to handle.- Author:
- Daniel Sagenschneider
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description HttpException(int statusCode, java.lang.String errorMessage)
Convenience constructor for providing error message.HttpException(java.lang.Throwable cause)
HttpException(HttpStatus status)
Instantiate.HttpException(HttpStatus status, java.lang.String errorMessage)
Convenience constructor for providing error message.HttpException(HttpStatus status, java.lang.Throwable cause)
Instantiate.HttpException(HttpStatus status, WritableHttpHeader[] headers, java.lang.String entity)
Instantiate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getEntity()
Obtains the entity for theHttpResponse
.HttpHeader[]
getHttpHeaders()
Obtains theHttpHeader
instances.HttpStatus
getHttpStatus()
Obtains theHttpStatus
for theHttpResponse
.java.lang.String
getMessage()
<B> void
writeHttpResponse(HttpVersion version, boolean isIncludeStackTrace, StreamBuffer<B> head, StreamBufferPool<B> bufferPool)
Writes the HTTP response for thisHttpException
.
-
-
-
Constructor Detail
-
HttpException
public HttpException(HttpStatus status)
Instantiate.- Parameters:
status
-HttpStatus
.
-
HttpException
public HttpException(HttpStatus status, java.lang.Throwable cause)
Instantiate.- Parameters:
status
-HttpStatus
.cause
-Throwable
cause.
-
HttpException
public HttpException(int statusCode, java.lang.String errorMessage)
Convenience constructor for providing error message.- Parameters:
statusCode
- Status code.errorMessage
- Error message.
-
HttpException
public HttpException(HttpStatus status, java.lang.String errorMessage)
Convenience constructor for providing error message.- Parameters:
status
-HttpStatus
.errorMessage
- Error message.
-
HttpException
public HttpException(HttpStatus status, WritableHttpHeader[] headers, java.lang.String entity)
Instantiate.- Parameters:
status
-HttpStatus
.headers
-HttpHeader
instances. May benull
.entity
- Entity for theHttpResponse
. May benull
.
-
HttpException
public HttpException(java.lang.Throwable cause)
- Parameters:
cause
-Throwable
cause.
-
-
Method Detail
-
getHttpStatus
public HttpStatus getHttpStatus()
Obtains theHttpStatus
for theHttpResponse
.- Returns:
HttpStatus
for theHttpResponse
.
-
getHttpHeaders
public HttpHeader[] getHttpHeaders()
Obtains theHttpHeader
instances.- Returns:
HttpHeader
instances.
-
getEntity
public java.lang.String getEntity()
Obtains the entity for theHttpResponse
.- Returns:
- Entity for the
HttpResponse
.
-
writeHttpResponse
public <B> void writeHttpResponse(HttpVersion version, boolean isIncludeStackTrace, StreamBuffer<B> head, StreamBufferPool<B> bufferPool)
Writes the HTTP response for thisHttpException
.- Type Parameters:
B
- Buffer type.- Parameters:
version
-HttpVersion
.isIncludeStackTrace
- Whether to include the stack trace.head
- HeadStreamBuffer
of the linked list ofStreamBuffer
instances.bufferPool
-StreamBufferPool
.
-
getMessage
public java.lang.String getMessage()
- Overrides:
getMessage
in classjava.lang.Throwable
-
-