use of org.talend.types.test.generalobjects.errorhandling._1.ExceptionType in project arctic-sea by 52North.
the class OwsEncoderv110 method encodeOwsException.
@SuppressFBWarnings("DM_DEFAULT_ENCODING")
private ExceptionDocument encodeOwsException(CodedException owsException) {
ExceptionDocument exceptionDoc = ExceptionDocument.Factory.newInstance(getXmlOptions());
ExceptionType exceptionType = exceptionDoc.addNewException();
String exceptionCode;
if (owsException.getCode() == null) {
exceptionCode = OwsExceptionCode.NoApplicableCode.toString();
} else {
exceptionCode = owsException.getCode().toString();
}
exceptionType.setExceptionCode(exceptionCode);
if (owsException.getLocator() != null) {
exceptionType.setLocator(owsException.getLocator());
}
final StringBuilder exceptionText = new StringBuilder();
if (owsException.getMessage() != null) {
exceptionText.append(owsException.getMessage());
exceptionText.append("\n");
}
if (owsException.getCause() != null) {
exceptionText.append("[EXEPTION]: \n");
final String localizedMessage = owsException.getCause().getLocalizedMessage();
final String message = owsException.getCause().getMessage();
if (localizedMessage != null && message != null) {
if (!message.equals(localizedMessage)) {
exceptionText.append(message).append('\n');
}
exceptionText.append(localizedMessage).append('\n');
} else if (localizedMessage != null) {
exceptionText.append(localizedMessage).append('\n');
} else if (message != null) {
exceptionText.append(message).append('\n');
}
if (includeStackTraceInExceptionReport) {
final ByteArrayOutputStream os = new ByteArrayOutputStream();
owsException.getCause().printStackTrace(new PrintStream(os));
exceptionText.append(os.toString());
}
}
exceptionType.addExceptionText(exceptionText.toString());
return exceptionDoc;
}
Aggregations