use of org.apache.olingo.commons.api.ex.ODataError in project teiid by teiid.
the class BaseQueryExecution method buildError.
protected TranslatorException buildError(BinaryWSProcedureExecution execution) {
// do some error handling
try {
Blob blob = (Blob) execution.getOutputParameterValues().get(0);
if (blob != null) {
boolean json = false;
// $NON-NLS-1$
String contentTypeString = getHeader(execution, "Content-Type");
if (contentTypeString != null) {
ContentType contentType = ContentType.parse(contentTypeString);
if (contentType != null && ContentType.APPLICATION_JSON.isCompatible(contentType)) {
json = true;
}
}
ODataDeserializer parser = null;
if (json) {
parser = new JsonDeserializer(false);
} else {
// TODO: it may not be atom, it could just be xml/html
parser = new AtomDeserializer();
}
ODataError error = parser.toError(blob.getBinaryStream());
return new TranslatorException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID17013, execution.getResponseCode(), error.getCode(), error.getMessage(), error.getInnerError()));
}
return new TranslatorException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID17031, execution.getResponseCode()));
} catch (Throwable t) {
return new TranslatorException(t);
}
}
Aggregations