Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
Expand Down Expand Up @@ -108,6 +109,12 @@ Object executeWithParams(String qualifiedClassName, String methodName, Object...
}


} catch (InvocationTargetException e) {
Throwable target = e.getTargetException();
String errMsg = format("Java exec(): Invocation failed for method %s in class %s. Cause: %s",
methodName, qualifiedClassName, target);
LOGGER.error(errMsg, target);
throw new RuntimeException(errMsg, e);
} catch (Exception e) {
String errMsg = format("Java exec(): Invocation failed for method %s in class %s", methodName, qualifiedClassName);
LOGGER.error(errMsg + ". Exception - " + e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public void willPropagateExceptions() throws Exception {
});
exception.printStackTrace();
assertThat(exception.getMessage(), containsString("Invocation failed for method squareRoot"));
assertThat(exception.getMessage(), containsString("Cause: java.lang.RuntimeException: Can not square root a negative number"));
// The target exception is included in this exception (inside of the InvocationTargetException)
assertThat(exception.getCause(), is(notNullValue()));
assertThat(((InvocationTargetException)exception.getCause()).getTargetException().getMessage(),
Expand Down
Loading