public ODataResponse wrapInExceptionResponse(final Exception exception) { try { final Exception toHandleException = extractException(exception); fillErrorContext(toHandleException); if (toHandleException instanceof ODataApplicationException) { enhanceContextWithApplicationException((ODataApplicationException) toHandleException); } else if (toHandleException instanceof ODataMessageException) { enhanceContextWithMessageException((ODataMessageException) toHandleException); } ODataResponse oDataResponse; if (callback != null) { oDataResponse = handleErrorCallback(callback); } else { oDataResponse = EntityProvider.writeErrorDocument(errorContext); } if (!oDataResponse.containsHeader(org.apache.olingo.odata2.api.commons.HttpHeaders.CONTENT_TYPE)) { oDataResponse = ODataResponse.fromResponse(oDataResponse).contentHeader(contentType).build(); } return oDataResponse; } catch (Exception e) { ODataResponse response = ODataResponse.entity("Exception during error handling occured!") .contentHeader(ContentType.TEXT_PLAIN.toContentTypeString()) .status(HttpStatusCodes.INTERNAL_SERVER_ERROR).build(); return response; } }
public ODataResponse wrapInExceptionResponse(final Exception exception) { try { final Exception toHandleException = extractException(exception); fillErrorContext(toHandleException); if (toHandleException instanceof ODataApplicationException) { enhanceContextWithApplicationException((ODataApplicationException) toHandleException); } else if (toHandleException instanceof ODataRuntimeApplicationException) { enhanceContextWithRuntimeApplicationException((ODataRuntimeApplicationException) toHandleException); } else if (toHandleException instanceof ODataMessageException) { enhanceContextWithMessageException((ODataMessageException) toHandleException); } ODataResponse oDataResponse; if (callback != null) { oDataResponse = handleErrorCallback(callback); } else { oDataResponse = EntityProvider.writeErrorDocument(errorContext); } if (!oDataResponse.containsHeader(org.apache.olingo.odata2.api.commons.HttpHeaders.CONTENT_TYPE)) { oDataResponse = ODataResponse.fromResponse(oDataResponse).contentHeader(contentType).build(); } return oDataResponse; } catch (Exception e) { ODataResponse response = ODataResponse.entity("Exception during error handling occured!") .contentHeader(ContentType.TEXT_PLAIN.toContentTypeString()) .status(HttpStatusCodes.INTERNAL_SERVER_ERROR).build(); return response; } }
public ODataResponse wrapInExceptionResponse(final Exception exception) { try { final Exception toHandleException = extractException(exception); fillErrorContext(toHandleException); if (toHandleException instanceof ODataApplicationException) { enhanceContextWithApplicationException((ODataApplicationException) toHandleException); } else if (toHandleException instanceof ODataRuntimeApplicationException) { enhanceContextWithRuntimeApplicationException((ODataRuntimeApplicationException) toHandleException); } else if (toHandleException instanceof ODataMessageException) { enhanceContextWithMessageException((ODataMessageException) toHandleException); } ODataResponse oDataResponse; if (callback != null) { oDataResponse = handleErrorCallback(callback); } else { oDataResponse = EntityProvider.writeErrorDocument(errorContext); } if (!oDataResponse.containsHeader(org.apache.olingo.odata2.api.commons.HttpHeaders.CONTENT_TYPE)) { oDataResponse = ODataResponse.fromResponse(oDataResponse).contentHeader(contentType).build(); } return oDataResponse; } catch (Exception e) { ODataResponse response = ODataResponse.entity("Exception during error handling occured!") .contentHeader(ContentType.TEXT_PLAIN.toContentTypeString()) .status(HttpStatusCodes.INTERNAL_SERVER_ERROR).build(); return response; } }