opendap/dtswar/src/main/java/opendap/dts/DTSServlet.java
public void dap2ExceptionHandler(DAP2Exception de, HttpServletResponse response)
    {
        //log.info("DODSServlet.dodsExceptionHandler (" + de.getErrorCode() + ") " + de.getErrorMessage());

        if(Debug.isSet("showException")) {
            log.error(de.toString());
            de.printStackTrace();
            printDODSException(de);
        }

        // Convert Dap2Excaption code to an HttpCode
        switch (de.getErrorCode()) {
        case DAP2Exception.NO_SUCH_FILE:
        case DAP2Exception.CANNOT_READ_FILE:
            response.setStatus(HttpStatus.SC_NOT_FOUND);
            break;
        case DAP2Exception.NO_AUTHORIZATION:
            response.setStatus(HttpStatus.SC_UNAUTHORIZED);
            break;
        case DAP2Exception.NO_SUCH_VARIABLE:
        case DAP2Exception.MALFORMED_EXPR:
        case DAP2Exception.UNKNOWN_ERROR: // fall thru
        default:
            response.setStatus(HttpStatus.SC_BAD_REQUEST);
            break;
        }

        try {
            BufferedOutputStream eOut = new BufferedOutputStream(response.getOutputStream());

            response.setHeader("Content-Description", "dods-error");

            // This should probably be set to "plain" but this works, the
            // C++ slients don't barf as they would if I sent "plain" AND
            // the C++ don't expect compressed data if I do this...
            response.setHeader("Content-Encoding", "");

            de.print(eOut);

        } catch (IOException ioe) {
            log.error("Cannot respond to client! IO Error: " + ioe.getMessage());
        }

    }
public void dap2ExceptionHandler(DAP2Exception de, HttpServletResponse response)
    {
        //log.info("DODSServlet.dodsExceptionHandler (" + de.getErrorCode() + ") " + de.getErrorMessage());

        if(Debug.isSet("showException")) {
            log.error(de.toString());
            de.printStackTrace();
            printDODSException(de);
        }

        // Convert Dap2Excaption code to an HttpCode
        switch (de.getErrorCode()) {
        case DAP2Exception.NO_SUCH_FILE:
        case DAP2Exception.CANNOT_READ_FILE:
            response.setStatus(HttpStatus.SC_NOT_FOUND);
            break;
        case DAP2Exception.NO_AUTHORIZATION:
            response.setStatus(HttpStatus.SC_UNAUTHORIZED);
            break;
        case DAP2Exception.NO_SUCH_VARIABLE:
        case DAP2Exception.MALFORMED_EXPR:
        case DAP2Exception.UNKNOWN_ERROR: // fall thru
        default:
            response.setStatus(HttpStatus.SC_BAD_REQUEST);
            break;
        }

        try {
            BufferedOutputStream eOut = new BufferedOutputStream(response.getOutputStream());

            response.setHeader("Content-Description", "dods-error");

            // This should probably be set to "plain" but this works, the
            // C++ slients don't barf as they would if I sent "plain" AND
            // the C++ don't expect compressed data if I do this...
            response.setHeader("Content-Encoding", "");

            de.print(eOut);

        } catch (IOException ioe) {
            log.error("Cannot respond to client! IO Error: " + ioe.getMessage());
        }

    }
Sends a OPeNDAP DAP2 error to the client.

@param de       The OPeNDAP DAP2 exception that caused the problem.
@param response The <code>HttpServletResponse</code> for the client.