protected void handleError(final Throwable throwable, final Request request, final Response response) { final ErrorCallback<?> errorCallback = getErrorCallback(); if (errorCallback != null) { if (errorCallback instanceof RestErrorCallback) { ((RestErrorCallback) errorCallback).error(request, throwable); } else { /* * Because of type erasure, there's no way to know if an ErrorCallback that doesn't implement RestErrorCallback takes * a request as an argument. But in some cases we want to wrap callbacks (such as in Caller<T>) to further control when * they are executed, and this is done in code upstream of RestErrorCallback. * * Thus, here we simply try to invoke with a request, and fallback to passing null if we get a casting exception. */ try { ((ErrorCallback<? super Request>) errorCallback).error(request, throwable); } catch (final ClassCastException e) { logger.debug("Class cast exception when invoking error callback with request object: {}", request); logger.debug("Invoking error callback again with null."); errorCallback.error(null, throwable); } } } else { GWT.log(throwable.getMessage(), throwable); } }
final ErrorCallback<?> errorCallback = getErrorCallback(); if (hasExceptionMapper()) { throwable = unmarshallException(response);