@ Override public void sendError ( HttpError error ) throws MessageSentException { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Called sendError with: " + error ) ; } if ( ! headersParsed ( ) ) { // request message must have the headers parsed prior to sending // any data out (this is a completely invalid state in the channel // above) // In this case, the app should not be re-using this so just close it IOException ioe = new IOException ( "Request not read yet" ) ; FFDCFilter . processException ( ioe , CLASS_NAME + ".sendError" , "1116" ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Attempt to send response without a request msg" ) ; } finishSendError ( ioe ) ; return ; } // bail if the headers have already been sent if ( headersSent ( ) ) { throw new MessageSentException ( "Message already sent" ) ; } // ensure error is legal if ( null == error ) { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { Tr . debug ( tc , "Reset null error to Internal Server Error" ) ; } error = StatusCodes . INTERNAL_ERROR . getHttpError ( ) ; } // set up the response message and then send it out getResponse ( ) . setStatusCode ( error . getErrorCode ( ) ) ; if ( getResponse ( ) . getStatusCode ( ) . isErrorCode ( ) ) { // PK30169 - some "error" status codes do not disable persistence setPersistent ( false ) ; } getVC ( ) . getStateMap ( ) . put ( HTTP_ERROR_IDENTIFIER , error ) ; if ( getHttpConfig ( ) . getDebugLog ( ) . isEnabled ( DebugLog . Level . ERROR ) ) { getHttpConfig ( ) . getDebugLog ( ) . log ( DebugLog . Level . ERROR , HttpMessages . MSG_CONN_SENDERROR + error . getErrorCode ( ) , this ) ; } // now figure out what buffers, if any, to send as the response body WsByteBuffer [ ] body = loadErrorBody ( error , getMyRequest ( ) , getResponse ( ) ) ; VirtualConnection rc = finishResponseMessage ( body , HttpISCWriteErrorCallback . getRef ( ) , false ) ; if ( null != rc ) { finishSendError ( error . getClosingException ( ) ) ; } }
Sends an error code and page back to the client asynchronously and closes the connection .