private void handleError( long status, NginxClojureAsynChannel upstream, NginxHttpServerChannel downstream) throws IOException { upstream.close(); if (downstream.getContext() == "sent") { downstream.send( "\r\n************Error Happended************\r\n" + upstream.buildError(status), true, true); log.warn("error happened: %s", upstream.buildError(status)); } else { downstream.sendResponse( new Object[] { 500, ArrayMap.create("Content-Type", "text/html"), upstream.buildError(status) }); } }