void handleServerError(final ODataRequest request, final ODataResponse response, final ODataServerError serverError) { try { ODataSerializer serializer = this.odata.createSerializer(this.contentType); ErrorResponse errorResponse = new ErrorResponse(this.metadata, serializer, this.contentType, response); handler.processError(serverError, errorResponse); } catch (Exception e) { // This should never happen but to be sure we have this catch here // to prevent sending a stacktrace to a client. String responseContent = "{\"error\":{\"code\":null,\"message\":\"An unexpected exception occurred during " + "error processing with message: " + e.getMessage() + "\"}}"; //$NON-NLS-1$ //$NON-NLS-2$ response.setContent(new ByteArrayInputStream(responseContent.getBytes())); response.setStatusCode(HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode()); response.setHeader(HttpHeader.CONTENT_TYPE, ContentType.APPLICATION_JSON.toContentTypeString()); } } }
void handleServerError(final ODataRequest request, final ODataResponse response, final ODataServerError serverError) { try { ODataSerializer serializer = this.odata.createSerializer(this.contentType); ErrorResponse errorResponse = new ErrorResponse(this.metadata, serializer, this.contentType, response); handler.processError(serverError, errorResponse); } catch (Exception e) { // This should never happen but to be sure we have this catch here // to prevent sending a stacktrace to a client. String responseContent = "{\"error\":{\"code\":null,\"message\":\"An unexpected exception occurred during " + "error processing with message: " + e.getMessage() + "\"}}"; //$NON-NLS-1$ //$NON-NLS-2$ response.setContent(new ByteArrayInputStream(responseContent.getBytes())); response.setStatusCode(HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode()); response.setHeader(HttpHeader.CONTENT_TYPE, ContentType.APPLICATION_JSON.toContentTypeString()); } } }