diff --git a/app/src/main/java/io/appium/uiautomator2/utils/ReflectionUtils.java b/app/src/main/java/io/appium/uiautomator2/utils/ReflectionUtils.java index 9cd02868f..2b5967250 100644 --- a/app/src/main/java/io/appium/uiautomator2/utils/ReflectionUtils.java +++ b/app/src/main/java/io/appium/uiautomator2/utils/ReflectionUtils.java @@ -20,6 +20,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Arrays; @@ -80,8 +81,9 @@ public static void setField(final String fieldName, final Object value, final Ob public static Object invoke(final Method method, final Object object, final Object... parameters) { try { return method.invoke(object, parameters); - } catch (Exception e) { - throw new UiAutomator2Exception(String.format("Cannot invoke method %s on object %s with parameters %s", + } catch (IllegalAccessException | InvocationTargetException e) { + throw new UiAutomator2Exception(String.format( + "Cannot invoke method %s on object %s with parameters %s", method, object, Arrays.toString(parameters)), e); } }