*/
public static void handleError(DAVException error, HttpServletResponse servletResponse) throws IOException {
SVNDebugLog.getDefaultLog().logFine(SVNLogType.NETWORK, error);
DAVResponse response = error.getResponse();
if (response == null) {
DAVException stackErr = error;
while (stackErr != null && stackErr.getTagName() == null) {
stackErr = stackErr.getPreviousException();
}
if (stackErr != null && stackErr.getTagName() != null) {
servletResponse.setContentType(XML_CONTENT_TYPE);
servletResponse.setStatus(stackErr.getResponseCode());
StringBuffer errorMessageBuffer = new StringBuffer();
SVNXMLUtil.addXMLHeader(errorMessageBuffer);
errorMessageBuffer.append('\n');
errorMessageBuffer.append("<D:error xmlns:D=\"DAV:\"");
if (stackErr.getMessage() != null) {
errorMessageBuffer.append(" xmlns:m=\"http://apache.org/dav/xmlns\"");
}
if (stackErr.getNameSpace() != null) {
errorMessageBuffer.append(" xmlns:C=\"");
errorMessageBuffer.append(stackErr.getNameSpace());
errorMessageBuffer.append("\">\n<C:");
errorMessageBuffer.append(stackErr.getTagName());
errorMessageBuffer.append("/>");
} else {
errorMessageBuffer.append(">\n<D:");
errorMessageBuffer.append(stackErr.getTagName());
errorMessageBuffer.append("/>");
}
if (stackErr.getMessage() != null) {
errorMessageBuffer.append("<m:human-readable errcode=\"");
errorMessageBuffer.append(stackErr.getErrorID());
errorMessageBuffer.append("\">\n");
errorMessageBuffer.append(SVNEncodingUtil.xmlEncodeCDATA(stackErr.getMessage()));
errorMessageBuffer.append('\n');
errorMessageBuffer.append("</m:human-readable>\n");
}
errorMessageBuffer.append("</D:error>\n");
servletResponse.getWriter().print(errorMessageBuffer.toString());