@Override public void processError(ODataServerError error, ErrorResponse response) { response.writeError(error); } }
public void visit(ErrorResponse response) { response.writeServerError(true); } }
public void writeError(ODataServerError error) { try { writeHeader(HttpHeader.CONTENT_TYPE, this.contentType.toContentTypeString()); writeContent(this.serializer.error(error).getContent(), error.getStatusCode(), true); } catch (SerializerException e) { writeServerError(true); } } }
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()); } } }
public void writeError(ODataServerError error) { try { writeHeader(HttpHeader.CONTENT_TYPE, this.contentType.toContentTypeString()); writeContent(this.serializer.error(error).getContent(), error.getStatusCode(), true); } catch (SerializerException e) { writeServerError(true); } } }
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()); } } }
@Override public void processError(ODataServerError error, ErrorResponse response) { response.writeError(error); } }
public void visit(ErrorResponse response) { response.writeServerError(true); } }
@Override public void processError(ODataServerError oDataServerError, ErrorResponse errorResponse) { String error = "Error occurred. :" + oDataServerError.getMessage(); oDataServerError.setMessage(error); log.error(error, oDataServerError.getException()); errorResponse.writeError(oDataServerError); }
response.writeError(error);