A bug that I used to correct in my code and that should be resolved definitly now ;-) As it's a very old bug (since the first versions), I guess there is few users of the Utility, no ?
Here it goes :
Exception in thread "main" java.lang.ClassCastException: org.apache.axis.AxisFault cannot be cast to com.google.api.ads.adwords.axis.v201506.cm.ApiException
at com.google.api.ads.adwords.axis.utility.extension.exception.UtilityLibraryException.getUnwrapApiExceptions(UtilityLibraryException.java:98)
at com.google.api.ads.adwords.axis.utility.extension.util.ReflectionUtil.invokeCount(ReflectionUtil.java:142)
at com.google.api.ads.adwords.axis.utility.extension.util.ReflectionUtil.invokeCount(ReflectionUtil.java:74)
And this is what I use to add in UtilityLibraryException.java :
/**
* Unwraps ApiException, AxisFault and RemoteException exceptions
*
* @param exception the {@code Exception} to unwrap
* @param message custom message to include in the UtilityLibraryException
* @throws RemoteException for communication-related exceptions
*/
public static void throwUnwrapApiExceptions(Exception exception, String message)
throws RemoteException {
Throwable throwable = Throwables.getRootCause(exception);
if (throwable.getClass().isAssignableFrom(ApiException.class)) {
throw (ApiException) throwable;
}
if (throwable.getClass().isAssignableFrom(RemoteException.class)) {
throw (RemoteException) throwable;
}
if (throwable.getClass().isAssignableFrom(AxisFault.class)) {
throw (AxisFault) throwable;
}
throw new UtilityLibraryException(message, exception);
}
/**
* Unwraps ApiException, AxisFault and RemoteException exceptions
*
* @param exception the {@code Exception} to unwrap
* @param message custom message to include in the UtilityLibraryException
* @return the unwrapped RemoteException
*/
public static RemoteException getUnwrapApiExceptions(Exception exception, String message) {
Throwable throwable = Throwables.getRootCause(exception);
if (throwable.getClass().isAssignableFrom(ApiException.class)
&& !throwable.getClass().equals(RemoteException.class)
&& !throwable.getClass().equals(AxisFault.class)) {
return (ApiException) throwable;
}
if (throwable.getClass().isAssignableFrom(RemoteException.class)) {
return (RemoteException) throwable;
}
if (throwable.getClass().isAssignableFrom(AxisFault.class)) {
return (AxisFault) throwable;
}
return new RemoteException(message + " " + throwable.getMessage(), throwable);
}
Cheers.
David Botella
Reactions are currently unavailable
A bug that I used to correct in my code and that should be resolved definitly now ;-) As it's a very old bug (since the first versions), I guess there is few users of the Utility, no ?
Here it goes :
And this is what I use to add in UtilityLibraryException.java :
Cheers.
David Botella