Hi i finally got the solution:
In Olingo V2 it is possible to override the "getCallback" method to use an own implementation of an ODataErrorCallback.
Documentation can be found here: http://olingo.staging.apache.org/doc/odata2/tutorials/debug.html#error-callback
And a sample here: org.apache.olingo.odata2.ref.processor.ScenarioServiceFactory
In our use case you could (as simple example) add below listed code below into your code (or as example the JPA reference scenario factory (org.apache.olingo.odata2.jpa.processor.ref.web.JPAReferenceServiceFactory)).
@Override
public <T extends ODataCallback> T getCallback(Class<T> callbackInterface) {
if(callbackInterface.isAssignableFrom(ODataErrorCallback.class)) {
return (T) new MySampleErrorCallback();
}
return super.getCallback(callbackInterface);
}
private class MySampleErrorCallback implements ODataErrorCallback {
@Override
public ODataResponse handleError(ODataErrorContext context) throws ODataApplicationException {
LOG.error("Error...");
return EntityProvider.writeErrorDocument(context);
}
}