}
public static ExceptionReportType exceptionReport(
ServiceException exception, boolean verboseExceptions) {
ExceptionType e = f.createExceptionType();
if (exception.getCode() != null) {
e.setExceptionCode(exception.getCode());
} else {
//set a default
e.setExceptionCode("NoApplicableCode");
}
e.setLocator(exception.getLocator());
//add the message
StringBuffer sb = new StringBuffer();
OwsUtils.dumpExceptionMessages(exception, sb, true);
e.getExceptionText().add(sb.toString());
e.getExceptionText().addAll(exception.getExceptionText());
if(verboseExceptions) {
//add the entire stack trace
//exception.
e.getExceptionText().add("Details:");
ByteArrayOutputStream trace = new ByteArrayOutputStream();
exception.printStackTrace(new PrintStream(trace));
e.getExceptionText().add(new String(trace.toByteArray()));
}
ExceptionReportType report = f.createExceptionReportType();
report.setVersion("1.1.0");
report.getException().add(e);