Cleanup.
This commit is contained in:
parent
7dc9a51a7f
commit
1ab96e5b3a
2 changed files with 10 additions and 12 deletions
|
@ -35,7 +35,7 @@ package net.thauvin.erik.httpstatus;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The <code>StatusCode</code> class implements methods to check the class of a HTTP status code.
|
* The <code>StatusCode</code> bean implements methods to check the class of an HTTP status code.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:erik@thauvin.net" target="_blank">Erik C. Thauvin</a>
|
* @author <a href="mailto:erik@thauvin.net" target="_blank">Erik C. Thauvin</a>
|
||||||
*/
|
*/
|
||||||
|
@ -44,10 +44,10 @@ public class StatusCode implements Serializable {
|
||||||
private int code;
|
private int code;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new statusCode object.
|
* Creates a new StatusCode object.
|
||||||
*/
|
*/
|
||||||
public StatusCode() {
|
public StatusCode() {
|
||||||
// Default construtor.
|
// Default constructor.
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,13 +70,14 @@ public class StatusCode implements Serializable {
|
||||||
* Returns the reason for the status code.
|
* Returns the reason for the status code.
|
||||||
*
|
*
|
||||||
* @return The reason, or <code>null</code>.
|
* @return The reason, or <code>null</code>.
|
||||||
|
* @see Reasons#getReasonPhrase(int)
|
||||||
*/
|
*/
|
||||||
public String getReason() {
|
public String getReason() {
|
||||||
return Reasons.getReasonPhrase(code);
|
return Reasons.getReasonPhrase(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the status code is a client error. (eg: <code>Interal Server Error</code>)
|
* Checks if the status code is a client error. (eg: <code>Internal Server Error</code>)
|
||||||
*
|
*
|
||||||
* @return <code>true</code> if the status code is a client error, <code>false</code> otherwise.
|
* @return <code>true</code> if the status code is a client error, <code>false</code> otherwise.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -54,16 +54,13 @@ public class CauseTag extends XmlSupport {
|
||||||
final PageContext pageContext = (PageContext) getJspContext();
|
final PageContext pageContext = (PageContext) getJspContext();
|
||||||
@SuppressWarnings("PMD.CloseResource") final JspWriter out = pageContext.getOut();
|
@SuppressWarnings("PMD.CloseResource") final JspWriter out = pageContext.getOut();
|
||||||
|
|
||||||
String cause;
|
final Throwable cause = pageContext.getErrorData().getThrowable().getCause();
|
||||||
|
|
||||||
try {
|
String message = defaultValue;
|
||||||
cause = pageContext.getErrorData().getThrowable().getCause().getLocalizedMessage();
|
if (cause != null && cause.getLocalizedMessage() != null) {
|
||||||
} catch (NullPointerException ignore) {
|
message = cause.getLocalizedMessage();
|
||||||
cause = defaultValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils.outWrite(out, cause, defaultValue, escapeXml);
|
Utils.outWrite(out, message, defaultValue, escapeXml);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue