Skip to content

Commit

Permalink
fix: Do not wrap runtime exceptions caused by reflected method invoca…
Browse files Browse the repository at this point in the history
…tion (#431)
  • Loading branch information
mykola-mokhnach authored Jul 4, 2021
1 parent 56e2a75 commit 98ea07d
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 98ea07d

Please sign in to comment.