org.codehaus.groovy.runtime
Class StackTraceUtils

java.lang.Object
  extended by org.codehaus.groovy.runtime.StackTraceUtils

public class StackTraceUtils
extends java.lang.Object

Originally was grails.utils.GrailsUtils, removed some grails specific stuff. Utility methods removing internal lines from stack traces

Since:
0.2
Version:
$Revision: 5544 $ First Created: 02-Jun-2006 Last Updated: $Date: 2007-09-21 13:53:07 -0500 (Fri, 21 Sep 2007) $
Author:
Graeme Rocher

Field Summary
private static java.lang.String[] GROOVY_PACKAGES
           
private static java.util.logging.Logger STACK_LOG
           
static java.lang.String STACK_LOG_NAME
           
private static java.util.List<Closure> tests
           
 
Constructor Summary
StackTraceUtils()
           
 
Method Summary
static void addClassTest(Closure test)
          Adds a groovy.lang.Closure to test whether the stack trace element should be added or not.
static java.lang.Throwable deepSanitize(java.lang.Throwable t)
          Sanitize the exception and ALL nested causes
static java.lang.Throwable extractRootCause(java.lang.Throwable t)
          Extracts the root cause of the exception, no matter how nested it is
static boolean isApplicationClass(java.lang.String className)
           
static void printSanitizedStackTrace(java.lang.Throwable t)
           
static void printSanitizedStackTrace(java.lang.Throwable t, java.io.PrintWriter p)
           
static java.lang.Throwable sanitize(java.lang.Throwable t)
          Remove all apparently groovy-internal trace entries from the exception instance
static java.lang.Throwable sanitizeRootCause(java.lang.Throwable t)
          Get the root cause of an exception and sanitize it for display to the user
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STACK_LOG_NAME

public static final java.lang.String STACK_LOG_NAME
See Also:
Constant Field Values

STACK_LOG

private static final java.util.logging.Logger STACK_LOG

GROOVY_PACKAGES

private static final java.lang.String[] GROOVY_PACKAGES

tests

private static java.util.List<Closure> tests
Constructor Detail

StackTraceUtils

public StackTraceUtils()
Method Detail

addClassTest

public static void addClassTest(Closure test)

Adds a groovy.lang.Closure to test whether the stack trace element should be added or not.

The groovy.lang.Closure will be given the class name as parameter. the return value decides if the element will be added or not.

Groovy truth will be used to determine true and false, null is excluded from defaulting to false here. If all tests have been executed and all of them skipped, then the groovy standard filtering will take place.

Parameters:
test - the testing groovy.lang.Closure

sanitize

public static java.lang.Throwable sanitize(java.lang.Throwable t)

Remove all apparently groovy-internal trace entries from the exception instance

This modifies the original instance and returns it, it does not clone

Parameters:
t -
Returns:
The exception passed in, after cleaning the stack trace

printSanitizedStackTrace

public static void printSanitizedStackTrace(java.lang.Throwable t,
                                            java.io.PrintWriter p)

printSanitizedStackTrace

public static void printSanitizedStackTrace(java.lang.Throwable t)

isApplicationClass

public static boolean isApplicationClass(java.lang.String className)

extractRootCause

public static java.lang.Throwable extractRootCause(java.lang.Throwable t)

Extracts the root cause of the exception, no matter how nested it is

Parameters:
t -
Returns:
The deepest cause of the exception that can be found

sanitizeRootCause

public static java.lang.Throwable sanitizeRootCause(java.lang.Throwable t)

Get the root cause of an exception and sanitize it for display to the user

This will MODIFY the stacktrace of the root cause exception object and return it

Parameters:
t -
Returns:
The root cause exception instance, with its stace trace modified to filter out groovy runtime classes

deepSanitize

public static java.lang.Throwable deepSanitize(java.lang.Throwable t)

Sanitize the exception and ALL nested causes

This will MODIFY the stacktrace of the exception instance and all its causes irreversibly

Parameters:
t -
Returns:
The root cause exception instances, with stack trace modified to filter out groovy runtime classes


Copyright © ${year} The Codehaus. All Rights Reserved.