}
public static ExceptionReportType exceptionReport(ServiceException exception,
boolean verboseExceptions, String version) {
ExceptionType e = Ows20Factory.eINSTANCE.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);
sb.append("\n");
sb.append(exception.getExceptionText()); // check this
// e.getExceptionText().add(sb.toString());
// e.getExceptionText().addAll(exception.getExceptionText());
if(verboseExceptions) {
//add the entire stack trace
//exception.
sb.append("\nDetails:\n");
ByteArrayOutputStream trace = new ByteArrayOutputStream();
exception.printStackTrace(new PrintStream(trace));
sb.append(new String(trace.toByteArray()));
}
e.setExceptionText(sb.toString());
ExceptionReportType report = Ows20Factory.eINSTANCE.createExceptionReportType();
version = version != null ? version : "2.0.0";
report.setVersion(version);