public static Throwable sanitize(Throwable t){
  if (!Boolean.getBoolean("groovy.full.stacktrace")) {
    StackTraceElement[] trace=t.getStackTrace();
    List<StackTraceElement> newTrace=new ArrayList<StackTraceElement>();
    for (    StackTraceElement stackTraceElement : trace) {
      if (isApplicationClass(stackTraceElement.getClassName())) {
        newTrace.add(stackTraceElement);
      }
    }
    STACK_LOG.log(Level.WARNING,"Sanitizing stacktrace:",t);
    StackTraceElement[] clean=new StackTraceElement[newTrace.size()];
    newTrace.toArray(clean);
    t.setStackTrace(clean);
  }
  return t;
}

public static Throwable sanitize ( Throwable t ) { if ( ! Boolean . getBoolean ( "groovy.full.stacktrace" ) ) { StackTraceElement [ ] trace = t . getStackTrace ( ) ; List < StackTraceElement > newTrace = new ArrayList < StackTraceElement > ( ) ; for ( StackTraceElement stackTraceElement : trace ) { if ( isApplicationClass ( stackTraceElement . getClassName ( ) ) ) { newTrace . add ( stackTraceElement ) ; } } STACK_LOG . log ( Level . WARNING , "Sanitizing stacktrace:" , t ) ; StackTraceElement [ ] clean = new StackTraceElement [ newTrace . size ( ) ] ; newTrace . toArray ( clean ) ; t . setStackTrace ( clean ) ; } return t ; }
remove all apparently groovy - internal trace entries from the exception instance < p > this modifies the original instance and returns it , it does not clone
