Package org.codehaus.groovy.runtime
Class StackTraceUtils
java.lang.Object
org.codehaus.groovy.runtime.StackTraceUtils
Originally was grails.utils.GrailsUtils, removed some grails specific stuff.
Utility methods removing internal lines from stack traces
- Since:
- 1.5
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddClassTest(Closure test) Adds a groovy.lang.Closure to test whether the stack trace element should be added or not.static ThrowableSanitize the exception and ALL nested causesstatic ThrowableExtracts the root cause of the exception, no matter how nested it isstatic booleanisApplicationClass(String className) Determines whether the given class name is an application class (not a Groovy runtime class).static voidPrints the sanitized stack trace of the exception to standard error.static voidPrints the sanitized stack trace of the exception to the given writer.static ThrowableRemove all apparently groovy-internal trace entries from the exception instancestatic ThrowableGet the root cause of an exception and sanitize it for display to the user
-
Field Details
-
STACK_LOG_NAME
The logger name for sanitized stack traces.- See Also:
-
-
Method Details
-
addClassTest
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.
- true - trace element will be added to the trace
- false - trace element will not be added to the trace
- null - continue with next test
- Parameters:
test- the testing groovy.lang.Closure
-
sanitize
Remove all apparently groovy-internal trace entries from the exception instanceThis modifies the original instance and returns it, it does not clone
- Parameters:
t- the Throwable whose stack trace we want to sanitize- Returns:
- The original Throwable but with a sanitized stack trace
-
printSanitizedStackTrace
Prints the sanitized stack trace of the exception to the given writer. Removes apparently groovy-internal trace entries.- Parameters:
t- the Throwable whose stack trace to printp- the PrintWriter to print to
-
printSanitizedStackTrace
Prints the sanitized stack trace of the exception to standard error. Removes apparently groovy-internal trace entries.- Parameters:
t- the Throwable whose stack trace to print
-
isApplicationClass
Determines whether the given class name is an application class (not a Groovy runtime class). First checks any registered test closures, then checks against known Groovy packages.- Parameters:
className- the fully qualified class name to check- Returns:
trueif the class is an application class,falseif it's a Groovy runtime class
-
extractRootCause
Extracts the root cause of the exception, no matter how nested it is- Parameters:
t- a Throwable- Returns:
- The deepest cause of the exception that can be found
-
sanitizeRootCause
Get the root cause of an exception and sanitize it for display to the userThis will MODIFY the stacktrace of the root cause exception object and return it
- Parameters:
t- a throwable- Returns:
- The root cause exception instance, with its stace trace modified to filter out groovy runtime classes
-
deepSanitize
Sanitize the exception and ALL nested causesThis will MODIFY the stacktrace of the exception instance and all its causes irreversibly
- Parameters:
t- a throwable- Returns:
- The root cause exception instances, with stack trace modified to filter out groovy runtime classes
-