/** * Sanitize the exception and ALL nested causes * <p> * This will MODIFY the stacktrace of the exception instance and all its causes irreversibly * * @param t a throwable * @return The root cause exception instances, with stack trace modified to filter out groovy runtime classes */ public static Throwable deepSanitize(Throwable t) { Throwable current = t; while (current.getCause() != null) { current = StackTraceUtils.sanitize(current.getCause()); } return StackTraceUtils.sanitize(t); } }
public static void printSanitizedStackTrace(Throwable t, PrintWriter p) { t = StackTraceUtils.sanitize(t); StackTraceElement[] trace = t.getStackTrace(); for (StackTraceElement stackTraceElement : trace) { p.println("at " + stackTraceElement.getClassName() + "(" + stackTraceElement.getMethodName() + ":" + stackTraceElement.getLineNumber() + ")"); } }
/** * Get the root cause of an exception and sanitize it for display to the user * <p> * This will MODIFY the stacktrace of the root cause exception object and return it * * @param t a throwable * @return The root cause exception instance, with its stace trace modified to filter out groovy runtime classes */ public static Throwable sanitizeRootCause(Throwable t) { return StackTraceUtils.sanitize(StackTraceUtils.extractRootCause(t)); }
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; } }
private TryResult handleError(String scriptName, Throwable e) { TryResult either; if (e instanceof InvocationTargetException) { e = ((InvocationTargetException) e).getTargetException(); } if (e instanceof InterruptedException || e instanceof InvocationTargetException || e instanceof ThreadDeath) { either = TryResult.createError(INTERUPTED_MSG); } else { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); StackTraceUtils.sanitize(e).printStackTrace(pw); String value = sw.toString(); value = printStacktrace(scriptName, value); either = TryResult.createError(value); } return either; }
public void execute(final ExecuteContext context) throws Exception { try { getClosure().call(context); } catch (Throwable t) { t = StackTraceUtils.sanitize(t); if (t instanceof RuntimeException) { throw (RuntimeException) t; } if (t instanceof Exception) { throw (Exception) t; } if (t instanceof Error) { throw (Error) t; } throw new RuntimeException(t); } }
@Override public Model read(final Reader input, final Map<String, ?> options) throws IOException { assert input != null; Model model; try { model = doRead(input, options); } catch (Throwable t) { t = StackTraceUtils.sanitize(t); if (t instanceof IOException) { throw (IOException) t; } if (t instanceof RuntimeException) { throw (RuntimeException) t; } if (t instanceof Error) { throw (Error) t; } throw new RuntimeException(t); } // FIXME: Looks like there are cases where the model is loaded more than once executeManager.install(model, options); if (log.isDebugEnabled()) { DefaultModelWriter writer = new DefaultModelWriter(); StringWriter buff = new StringWriter(); writer.write(buff, null, model); log.debug("Read groovy model: \n" + buff); } return model; }
/** * <p>Sanitize the exception and ALL nested causes</p> * <p>This will MODIFY the stacktrace of the exception instance and all its causes irreversibly</p> * @param t * @return The root cause exception instances, with stack trace modified to filter out groovy runtime classes */ public static Throwable deepSanitize(Throwable t) { Throwable current = t; while (current.getCause() != null) { current = StackTraceUtils.sanitize(current.getCause()); } return StackTraceUtils.sanitize(t); } }
/** * <p>Sanitize the exception and ALL nested causes</p> * <p>This will MODIFY the stacktrace of the exception instance and all its causes irreversibly</p> * @param t * @return The root cause exception instances, with stack trace modified to filter out groovy runtime classes */ public static Throwable deepSanitize(Throwable t) { Throwable current = t; while (current.getCause() != null) { current = StackTraceUtils.sanitize(current.getCause()); } return StackTraceUtils.sanitize(t); } }
/** * <p>Sanitize the exception and ALL nested causes</p> * <p>This will MODIFY the stacktrace of the exception instance and all its causes irreversibly</p> * @param t * @return The root cause exception instances, with stack trace modified to filter out groovy runtime classes */ public static Throwable deepSanitize(Throwable t) { Throwable current = t; while (current.getCause() != null) { current = StackTraceUtils.sanitize(current.getCause()); } return StackTraceUtils.sanitize(t); } }
/** * <p>Sanitize the exception and ALL nested causes</p> * <p>This will MODIFY the stacktrace of the exception instance and all its causes irreversibly</p> * * @param t a throwable * @return The root cause exception instances, with stack trace modified to filter out groovy runtime classes */ public static Throwable deepSanitize(Throwable t) { Throwable current = t; while (current.getCause() != null) { current = StackTraceUtils.sanitize(current.getCause()); } return StackTraceUtils.sanitize(t); } }
public static void printSanitizedStackTrace(Throwable t, PrintWriter p) { t = StackTraceUtils.sanitize(t); StackTraceElement[] trace = t.getStackTrace(); for (int i = 0; i < trace.length; i++) { StackTraceElement stackTraceElement = trace[i]; p.println( "at "+stackTraceElement.getClassName() +"("+stackTraceElement.getMethodName() +":"+stackTraceElement.getLineNumber()+")"); } }
public static void printSanitizedStackTrace(Throwable t, PrintWriter p) { t = StackTraceUtils.sanitize(t); StackTraceElement[] trace = t.getStackTrace(); for (StackTraceElement stackTraceElement : trace) { p.println("at " + stackTraceElement.getClassName() + "(" + stackTraceElement.getMethodName() + ":" + stackTraceElement.getLineNumber() + ")"); } }
public static void printSanitizedStackTrace(Throwable t, PrintWriter p) { t = StackTraceUtils.sanitize(t); StackTraceElement[] trace = t.getStackTrace(); for (int i = 0; i < trace.length; i++) { StackTraceElement stackTraceElement = trace[i]; p.println( "at "+stackTraceElement.getClassName() +"("+stackTraceElement.getMethodName() +":"+stackTraceElement.getLineNumber()+")"); } }
public static void printSanitizedStackTrace(Throwable t, PrintWriter p) { t = StackTraceUtils.sanitize(t); StackTraceElement[] trace = t.getStackTrace(); for (int i = 0; i < trace.length; i++) { StackTraceElement stackTraceElement = trace[i]; p.println( "at "+stackTraceElement.getClassName() +"("+stackTraceElement.getMethodName() +":"+stackTraceElement.getLineNumber()+")"); } }
/** * <p>Get the root cause of an exception and sanitize it for display to the user</p> * <p>This will MODIFY the stacktrace of the root cause exception object and return it</p> * @param t * @return The root cause exception instance, with its stace trace modified to filter out groovy runtime classes */ public static Throwable sanitizeRootCause(Throwable t) { return StackTraceUtils.sanitize(StackTraceUtils.extractRootCause(t)); }
/** * <p>Get the root cause of an exception and sanitize it for display to the user</p> * <p>This will MODIFY the stacktrace of the root cause exception object and return it</p> * * @param t a throwable * @return The root cause exception instance, with its stace trace modified to filter out groovy runtime classes */ public static Throwable sanitizeRootCause(Throwable t) { return StackTraceUtils.sanitize(StackTraceUtils.extractRootCause(t)); }
/** * <p>Get the root cause of an exception and sanitize it for display to the user</p> * <p>This will MODIFY the stacktrace of the root cause exception object and return it</p> * @param t * @return The root cause exception instance, with its stace trace modified to filter out groovy runtime classes */ public static Throwable sanitizeRootCause(Throwable t) { return StackTraceUtils.sanitize(StackTraceUtils.extractRootCause(t)); }
/** * <p>Get the root cause of an exception and sanitize it for display to the user</p> * <p>This will MODIFY the stacktrace of the root cause exception object and return it</p> * @param t * @return The root cause exception instance, with its stace trace modified to filter out groovy runtime classes */ public static Throwable sanitizeRootCause(Throwable t) { return StackTraceUtils.sanitize(StackTraceUtils.extractRootCause(t)); }
public void execute(final ExecuteContext context) throws Exception { try { getClosure().call(context); } catch (Throwable t) { t = StackTraceUtils.sanitize(t); if (t instanceof RuntimeException) { throw (RuntimeException) t; } if (t instanceof Exception) { throw (Exception) t; } if (t instanceof Error) { throw (Error) t; } throw new RuntimeException(t); } }