Search in sources :

Example 1 with Located

use of io.cucumber.core.backend.Located in project cucumber-jvm by cucumber.

the class StackManipulation method removeFrameworkFrames.

static Throwable removeFrameworkFrames(CucumberInvocationTargetException invocationException) {
    Throwable error = invocationException.getInvocationTargetExceptionCause();
    StackTraceElement[] stackTraceElements = error.getStackTrace();
    Located located = invocationException.getLocated();
    int newStackTraceLength = findIndexOf(located, stackTraceElements);
    if (newStackTraceLength == -1) {
        return error;
    }
    StackTraceElement[] newStackTrace = new StackTraceElement[newStackTraceLength];
    System.arraycopy(stackTraceElements, 0, newStackTrace, 0, newStackTraceLength);
    error.setStackTrace(newStackTrace);
    return error;
}
Also used : Located(io.cucumber.core.backend.Located)

Example 2 with Located

use of io.cucumber.core.backend.Located in project cucumber-jvm by cucumber.

the class StackManipulation method removeFrameworkFramesAndAppendStepLocation.

static Throwable removeFrameworkFramesAndAppendStepLocation(CucumberInvocationTargetException invocationException, StackTraceElement stepLocation) {
    Located located = invocationException.getLocated();
    Throwable error = invocationException.getInvocationTargetExceptionCause();
    if (stepLocation == null) {
        return error;
    }
    StackTraceElement[] stackTraceElements = error.getStackTrace();
    int newStackTraceLength = findIndexOf(located, stackTraceElements);
    if (newStackTraceLength == -1) {
        return error;
    }
    StackTraceElement[] newStackTrace = new StackTraceElement[newStackTraceLength + 1];
    System.arraycopy(stackTraceElements, 0, newStackTrace, 0, newStackTraceLength);
    newStackTrace[newStackTraceLength] = stepLocation;
    error.setStackTrace(newStackTrace);
    return error;
}
Also used : Located(io.cucumber.core.backend.Located)

Aggregations

Located (io.cucumber.core.backend.Located)2