Java Code Examples for org.codehaus.groovy.runtime.StackTraceUtils#sanitize()

The following examples show how to use org.codehaus.groovy.runtime.StackTraceUtils#sanitize() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StreamingTemplateEngine.java    From groovy with Apache License 2.0 6 votes vote down vote up
public void error(int index, List<StringSection> sections, Throwable e) throws Throwable {
    int i = Math.max(0, index);
    StringSection precedingSection = sections.get(i);
    int traceLine = -1;
    for (StackTraceElement element : e.getStackTrace()) {
        if (element.getClassName().contains(TEMPLATE_SCRIPT_PREFIX)) {
            traceLine = element.getLineNumber();
            break;
        }
    }

    if (traceLine != -1) {
        int actualLine = precedingSection.lastSourcePosition.row + traceLine - 1;
        String message = "Template execution error at line " + actualLine + ":\n" + getErrorContext(actualLine);
        TemplateExecutionException unsanitized = new TemplateExecutionException(actualLine, message, StackTraceUtils.sanitize(e));
        throw StackTraceUtils.sanitize(unsanitized);
    } else {
        throw e;
    }
}
 
Example 2
Source File: Exceptions.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
public static void sanitize(Throwable t) {
	StackTraceUtils.sanitize(t);
	StackTraceUtils.sanitizeRootCause(t);
}