public class OPeNDAPException
extends java.lang.Exception
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
_systemPath |
static java.lang.String |
ERROR_RESPONSE_MEDIA_TYPE_KEY |
static int |
UNDEFINED_ERROR
Undefined error.
|
Modifier | Constructor and Description |
---|---|
protected |
OPeNDAPException()
Construct an empty
OPeNDAPException . |
|
OPeNDAPException(int code,
java.lang.String msg)
Construct a
OPeNDAPException with the given message. |
|
OPeNDAPException(int httpStatus,
java.lang.String msg,
java.lang.Throwable cause)
Construct a
OPeNDAPException . |
|
OPeNDAPException(int httpStatus,
java.lang.Throwable cause)
Construct a
OPeNDAPException . |
Modifier and Type | Method and Description |
---|---|
static int |
anyExceptionHandler(java.lang.Throwable t,
javax.servlet.http.HttpServlet servlet,
javax.servlet.http.HttpServletResponse response)
************************************************************************
Recasts any Throwable to be an OPeNDAPException and then transmits it
on to the passed stream as a DAP2 error object.
|
static java.lang.String |
getAndClearCachedErrorMessage() |
static java.lang.String |
getDap2Error(int code,
java.lang.String errorMessage) |
int |
getHttpStatusCode() |
java.lang.String |
getMessage()
Returns the detail message of this throwable object.
|
MediaType |
getResponseMediaType() |
void |
print(java.io.OutputStream os)
Print the DAP2 Error object on the given
OutputStream . |
void |
print(java.io.PrintStream os)
Print the DAP2 Error object on the given
PrintWriter . |
void |
sendAsCsvError(javax.servlet.http.HttpServletResponse response)
Transmits a CSV encoding of a DAP error object.
|
void |
sendAsDap2Error(javax.servlet.http.HttpServletResponse response)
Transmits a DAP2 encoding of the error object.
|
void |
sendAsDap4Error(javax.servlet.http.HttpServletResponse response)
Transmits a DAP4 encoding of the error object.
|
void |
sendAsHtmlErrorPage(javax.servlet.http.HttpServletResponse response) |
void |
sendAsJsonError(javax.servlet.http.HttpServletResponse response)
{
"name": "ERROR",
"type": "String",
"data": "Message"
}
|
void |
sendHttpErrorResponse(javax.servlet.http.HttpServletResponse response) |
static void |
setCachedErrorMessage(java.lang.String s) |
void |
setErrorMessage(java.lang.String msg)
Sets the error message.
|
int |
setHttpStatusCode(int code) |
void |
setResponseMediaType(MediaType mt) |
void |
setSystemPath(java.lang.String sysPath) |
public static final java.lang.String ERROR_RESPONSE_MEDIA_TYPE_KEY
public static final int UNDEFINED_ERROR
protected java.lang.String _systemPath
protected OPeNDAPException()
OPeNDAPException
.public OPeNDAPException(int httpStatus, java.lang.String msg, java.lang.Throwable cause)
OPeNDAPException
.msg
- A message describing the error.cause
- The cause (which is saved for later retrieval by the
Throwable.getCause() method). (A null value is permitted, and indicates
that the cause is nonexistent or unknown.)public OPeNDAPException(int httpStatus, java.lang.Throwable cause)
OPeNDAPException
.cause
- The cause (which is saved for later retrieval by the
Throwable.getCause() method). (A null value is permitted, and indicates
that the cause is nonexistent or unknown.)public OPeNDAPException(int code, java.lang.String msg)
OPeNDAPException
with the given message.code
- the error coremsg
- the error messagepublic void setResponseMediaType(MediaType mt)
public MediaType getResponseMediaType()
public void setSystemPath(java.lang.String sysPath)
public java.lang.String getMessage()
getMessage
in class java.lang.Throwable
public final void setErrorMessage(java.lang.String msg)
msg
- the error message.public static java.lang.String getDap2Error(int code, java.lang.String errorMessage)
public void print(java.io.PrintStream os)
PrintWriter
.
This code can be used by servlets to throw an OPeNDAPException to a client.os
- the PrintWriter
to use for output.public final void print(java.io.OutputStream os)
OutputStream
.os
- the OutputStream
to use for output.public static int anyExceptionHandler(java.lang.Throwable t, javax.servlet.http.HttpServlet servlet, javax.servlet.http.HttpServletResponse response)
t
- The Exception that caused the problem.response
- The HttpServletResponse
for the client.public void sendHttpErrorResponse(javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
java.lang.Exception
public int setHttpStatusCode(int code)
public int getHttpStatusCode()
public void sendAsDap2Error(javax.servlet.http.HttpServletResponse response) throws java.io.IOException
response
- The response object to load up with the error response.java.io.IOException
public void sendAsDap4Error(javax.servlet.http.HttpServletResponse response) throws java.io.IOException
response
- The response object to load up with the error response.java.io.IOException
public void sendAsCsvError(javax.servlet.http.HttpServletResponse response) throws java.io.IOException
response
- The response object to load up with the error response.java.io.IOException
public void sendAsJsonError(javax.servlet.http.HttpServletResponse response) throws java.io.IOException
response
- The response object to load up with the error response.java.io.IOException
public void sendAsHtmlErrorPage(javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
response
- The response object to load up with the error response.java.lang.Exception
public static java.lang.String getAndClearCachedErrorMessage()
public static void setCachedErrorMessage(java.lang.String s)