Java Code Examples for org.apache.olingo.odata2.api.processor.ODataErrorContext#setInnerError()
The following examples show how to use
org.apache.olingo.odata2.api.processor.ODataErrorContext#setInnerError() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XmlErrorDocumentConsumer.java From olingo-odata2 with Apache License 2.0 | 6 votes |
private void handleInnerError(final XMLStreamReader reader, final ODataErrorContext errorContext) throws XMLStreamException { StringBuilder sb = new StringBuilder(); while (notFinished(reader, FormatXml.M_INNER_ERROR)) { if (reader.hasName() && !FormatXml.M_INNER_ERROR.equals(reader.getLocalName())) { sb.append("<"); if (reader.isEndElement()) { sb.append("/"); } sb.append(reader.getLocalName()).append(">"); } else if (reader.isCharacters()) { sb.append(reader.getText()); } reader.next(); } errorContext.setInnerError(sb.toString()); }
Example 2
Source File: XmlErrorDocumentDeserializer.java From olingo-odata2 with Apache License 2.0 | 6 votes |
private void handleInnerError(final XMLStreamReader reader, final ODataErrorContext errorContext) throws XMLStreamException { StringBuilder sb = new StringBuilder(); while (notFinished(reader, FormatXml.M_INNER_ERROR)) { if (reader.hasName() && !FormatXml.M_INNER_ERROR.equals(reader.getLocalName())) { sb.append("<"); if (reader.isEndElement()) { sb.append("/"); } sb.append(reader.getLocalName()).append(">"); } else if (reader.isCharacters()) { sb.append(reader.getText()); } reader.next(); } errorContext.setInnerError(sb.toString()); }
Example 3
Source File: SimpleODataErrorCallback.java From cloud-sfsf-benefits-ext with Apache License 2.0 | 6 votes |
@Override public ODataResponse handleError(final ODataErrorContext context) throws ODataApplicationException { Throwable rootCause = context.getException(); LOGGER.error("Error in the OData. Reason: " + rootCause.getMessage(), rootCause); //$NON-NLS-1$ Throwable innerCause = rootCause.getCause(); if (rootCause instanceof ODataJPAException && innerCause != null && innerCause instanceof AppODataException) { context.setMessage(innerCause.getMessage()); Throwable childInnerCause = innerCause.getCause(); context.setInnerError(childInnerCause != null ? childInnerCause.getMessage() : ""); //$NON-NLS-1$ } else { context.setMessage(HttpStatusCodes.INTERNAL_SERVER_ERROR.getInfo()); context.setInnerError(rootCause.getMessage()); } context.setHttpStatus(HttpStatusCodes.INTERNAL_SERVER_ERROR); return EntityProvider.writeErrorDocument(context); }
Example 4
Source File: ODataJPAErrorCallback.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override public ODataResponse handleError(final ODataErrorContext context) throws ODataApplicationException { final String SEPARATOR = " : "; Throwable t = context.getException(); if (t instanceof ODataJPAException && t.getCause() != null) { StringBuilder errorBuilder = new StringBuilder(); errorBuilder.append(t.getCause().getClass().toString()); errorBuilder.append(SEPARATOR); errorBuilder.append(t.getCause().getMessage()); context.setInnerError(errorBuilder.toString()); } return EntityProvider.writeErrorDocument(context); }
Example 5
Source File: JsonErrorDocumentConsumer.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private void parseInnerError(final JsonReader reader, final ODataErrorContext errorContext) throws IOException { JsonToken token = reader.peek(); if (token == JsonToken.STRING) { // implementation for parse content as provided by JsonErrorDocumentProducer String innerError = reader.nextString(); errorContext.setInnerError(innerError); } else if (token == JsonToken.BEGIN_OBJECT) { // implementation for OData v2 Section 2.2.8.1.2 JSON Error Response // (RFC4627 Section 2.2 -> https://www.ietf.org/rfc/rfc4627.txt)) // currently partial provided errorContext.setInnerError(readJson(reader)); } }
Example 6
Source File: XmlErrorProducerTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void viaRuntimeDelegate() throws Exception { ODataErrorContext context = new ODataErrorContext(); context.setContentType(contentType); context.setHttpStatus(expectedStatus); context.setErrorCode(null); context.setMessage(null); context.setLocale(null); context.setInnerError(null); ODataResponse response = EntityProvider.writeErrorDocument(context); String errorXml = verifyResponse(response); verifyXml(null, null, null, null, errorXml); context.setErrorCode("a"); context.setMessage("a"); context.setLocale(Locale.GERMAN); context.setInnerError("a"); response = EntityProvider.writeErrorDocument(context); errorXml = verifyResponse(response); verifyXml("a", "a", Locale.GERMAN, "a", errorXml); context.setErrorCode(null); context.setInnerError(null); response = EntityProvider.writeErrorDocument(context); errorXml = verifyResponse(response); verifyXml(null, "a", Locale.GERMAN, null, errorXml); }
Example 7
Source File: JsonErrorDocumentDeserializer.java From olingo-odata2 with Apache License 2.0 | 5 votes |
/** * * @param reader * @param errorContext * @throws IOException */ private void parseInnerError(final JsonReader reader, final ODataErrorContext errorContext) throws IOException { JsonToken token = reader.peek(); if (token == JsonToken.STRING) { // implementation for parse content as provided by JsonErrorDocumentProducer String innerError = reader.nextString(); errorContext.setInnerError(innerError); } else if (token == JsonToken.BEGIN_OBJECT) { // implementation for OData v2 Section 2.2.8.1.2 JSON Error Response // (RFC4627 Section 2.2 -> https://www.ietf.org/rfc/rfc4627.txt)) // currently partial provided errorContext.setInnerError(readJson(reader)); } }