I am using Groovy in a Java Swing application as part of my plan to force-feed myself dynamic languages until I like them (which is happening, partly).
My stack traces are filled with Groovy stuff like
org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor
is there a way to get Eclipse to remove all of that codehaus
stuff (filter stack traces, basically)?
Edit: I can do this from the command-line with grep
(well, not yet) so it's not so bad, but inside of Eclipse would be great too.
There is a Utility in Groovy that does exactly what you want: StackTraceUtils. STU will clean all the callsite information from your stacktrace, leaving the stuff you're really interested in.
Edit: In Java you will have to encasulate the exception in a java.lang.RuntimeException
according to comments.
Example of usage:
try {
1/0;
} catch (Throwable t) {
throw new RuntimeException(org.codehaus.groovy.runtime.StackTraceUtils.sanitize(t)); //Modifies the Throwable and rethrows
}
StackTraceUtils is available in the latest version of Groovy and originally comes from Grails. I'm not sure how you would go about applying this to all of your projects stacktraces but I think both Griffon and Grails does it so there should be some hints in those projects.
I don't have an answer for "Run as Groovy application", but if you run GroovyTestcases as jUnit tests in Eclipse, there is a "filter stack traces" button above the stack trace view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With