diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataErrorResponseChecker.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataErrorResponseChecker.java index 274da3a07..2884acc14 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataErrorResponseChecker.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/header/ODataErrorResponseChecker.java @@ -19,6 +19,7 @@ package org.apache.olingo.client.core.communication.header; import java.io.InputStream; +import java.util.Map; import org.apache.http.StatusLine; import org.apache.olingo.client.api.ODataClient; @@ -57,6 +58,16 @@ public final class ODataErrorResponseChecker { ODataError error; try { error = odataClient.getReader().readError(entity, contentType); + if (error != null) { + Map innerError = error.getInnerError(); + if (innerError != null) { + if (innerError.get("internalexception") != null) { + error.setMessage(error.getMessage() + innerError.get("internalexception")); + } else { + error.setMessage(error.getMessage() + innerError.get("message")); + } + } + } } catch (final RuntimeException e) { LOG.warn("Error deserializing error response", e); error = getGenericError( diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/ErrorTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/ErrorTest.java index 4446e9250..f2e9af7a5 100644 --- a/lib/client-core/src/test/java/org/apache/olingo/client/core/ErrorTest.java +++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/ErrorTest.java @@ -92,7 +92,7 @@ public class ErrorTest extends AbstractTest { checkResponse(odataClient, statusLine, entity, "Json"); assertTrue(exp.getMessage().contains("(500) Internal Server Error")); ODataError error = exp.getODataError(); - assertEquals("Internal Server Error", error.getMessage()); + assertTrue(error.getMessage().startsWith("Internal Server Error")); assertEquals(500, Integer.parseInt(error.getCode())); assertEquals(2, error.getInnerError().size()); assertEquals("\"Method does not support entities of specific type\"", error.getInnerError().get("message")); @@ -111,6 +111,6 @@ public class ErrorTest extends AbstractTest { ODataServerErrorException exp = (ODataServerErrorException) ODataErrorResponseChecker. checkResponse(odataClient, statusLine, entity, "Json"); - assertEquals("Internal Server Error", exp.getMessage()); + assertTrue(exp.getMessage().startsWith("Internal Server Error")); } }