simple.http.serve
Class ErrorReport

java.lang.Object
  extended by simple.http.serve.ErrorReport
All Implemented Interfaces:
Report

public class ErrorReport
extends java.lang.Object
implements Report

The ErrorReport is used to describe HTTP errors. Reporting the various HTTP errors requires that status codes and textual descriptions of the errors are provided. This will pair a provided status code with a short description of the error that HTTP status code represents as outlined by RFC 2612 section 6.1.1.

The getCause method will provide a description of the error using the printStackTrace method. This enables the cause of the error to be identified within the source code of the file that threw the exception.

Author:
Niall Gallagher

Field Summary
protected static java.util.ResourceBundle error
          This is used to load the Error.properties file for a list of the matching HTTP error messages.
 
Constructor Summary
ErrorReport(java.lang.Throwable cause, int code)
          Constructor for the ErrorReport object.
 
Method Summary
 java.lang.String getCause()
          This is used to acquire a detailed message describing the cause of the error.
 int getCode()
          Returns the HTTP status code that this report represents.
 java.lang.String getText()
          Returns a short description of what caused this report.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

error

protected static java.util.ResourceBundle error
This is used to load the Error.properties file for a list of the matching HTTP error messages.

Constructor Detail

ErrorReport

public ErrorReport(java.lang.Throwable cause,
                   int code)
Constructor for the ErrorReport object. This will create an instance that uses the exception and the HTTP status code provided to describe the error event.

Parameters:
cause - this is the exception that caused the error
code - this is the HTTP status code of the error
Method Detail

getCode

public int getCode()
Returns the HTTP status code that this report represents. This will typically describe an error using one of the 4xx or 5xx HTTP status codes. For details on the specific types of status codes used by HTTP/1.1 see RFC 2616 section 6.1.1.

Specified by:
getCode in interface Report
Returns:
the HTTP status code this report represents

getText

public java.lang.String getText()
Returns a short description of what caused this report. This will typically describe an error using one of the 4xx or 5xx HTTP status codes. For details on the specific types of status codes used by HTTP/1.1 see RFC 2616 section 6.1.1.

Specified by:
getText in interface Report
Returns:
the short description of what caused the report

getCause

public java.lang.String getCause()
This is used to acquire a detailed message describing the cause of the error. This will display exceptions caught while processing a HTTP request. The exception message is acquired from the printStackTrace method.

Specified by:
getCause in interface Report
Returns:
a detailed description of what caused the report