{
Writer writer = httpResp.getWriter();
// can't use facesContext.getResponseWriter(), because it might not have been set
ResponseWriter responseWriter = new HtmlResponseWriterImpl(writer, "text/xml", "utf-8");
PartialResponseWriter partialWriter = new PartialResponseWriter(responseWriter);
partialWriter.startDocument();
partialWriter.startError(ex.getClass().getName());
if (ex.getCause() != null)
{
partialWriter.write(ex.getCause().toString());
}