RE: [coldbox:16255] [coldbox-3.5.2] Getting Stack Trace Array from ExceptionBean

Thanks for the suggestions. On #2, what are your thoughts on adding the actual error object to the ExceptionBean? That way, the duplicate can still occur but the exception object will still be available as well.

Well, if you are going to leave in the original error object, I wouldn’t see any point in leaving the duplicated version as well.

#3, though messy, is intriguing to me as well. I might have to explore that a bit, just for fun :slight_smile:

Yes, the reason it took me a bit to respond is because I actually got off in the weeds playing with that option just to see if you could do it. I eventually got caught up on my inferior grasp of regex. Basically, I was looping over the string stackTrace as a list with chr(10)&chr(13) as the delimiter. Then trying (unsuccessfully) to break out each line item which looks something like this:

into its separate parts which would look something like this:

className: coldfusion.runtime.CfJspPage
methodName: _get

lineNumber: 377

You can create a StackTraceElement like so once you have all the peices:
createObject(“java”, “java.lang.StackTraceElement”).init(“declaringClass”,“methodName”,“fileName”, lineNumber)

Like I said, I would consider that a last resort, but if you wanted to keep from touching the legacy site at all costs, and didn’t want to fiddle with core ColdBox, it should work.



ColdBox Platform Evangelist
Ortus Solutions, Corp

ColdBox Platform:

Hey Brad–

I played around a bit with the regex option, and I think I’ve got something working. My knowledge of regex is quite limited, so there are probably better ways to do this. However, I’ve thrown a number of different kinds of errors at this, and it seems to be working. Here’s the code if anyone is interested/would like to suggest improvements.


// array for all our stack trace elements
var tracers = [];
// loop over the list-to-array converted stacktrace
for( element in stacktrace ) {
// create the regex pattern
var pattern = CreateObject( “java”, “java.util.regex.Pattern” );
// compile the pattern; using 4 “or” matchers so we can get all the pieces we need in one pass
pattern.Compile( “(?<=at ).(?=…()|(?<=:).(?=)$)|(?<=().(?=:)|(?<=[a-zA-Z0-9].).*(?=()” );

// find the matches
var matcher = pattern.Matcher( element );
// create an array to store the items in our matched set
var tracer =[];
// for each match, add to our temp array
while( matcher.Find() ) {
arrayAppend( tracer, );
if( arrayLen( tracer ) == 4 ) {
arrayAppend( tracers, createObject( “java”, “java.lang.StackTraceElement” ).init( tracer[1], tracer[2], tracer[3], tracer[4]) );
else {
// do some kind of handling here


Hmm, sorry, pattern should be:

pattern = CreateObject( “java”, “java.util.regex.Pattern” ).Compile( “(?<=at ).(?=…()|(?<=:).(?=)$)|(?<=().(?=:)|(?<=[a-zA-Z0-9].).*(?=()” );