Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

parsing mozilla's Error stack property

2 views
Skip to first unread message

Java script Dude

unread,
Jan 5, 2006, 4:50:49 PM1/5/06
to
Has anybody hacked a stack parser for Mozilla Error stack property.

Some basic regular expressions would work well, but my time is a little
tight of late.

Basically I would like to parse out, function/method name, source path,
source name, line number.

Thanks,
JsD

Thomas 'PointedEars' Lahn

unread,
Jan 5, 2006, 6:14:50 PM1/5/06
to
Java script Dude wrote:

try
{
// don't declare x before
y = x;
}
catch (e)
{
var m, a = [];
while ((m = /^\s*(.*)@(.+):(\d+)\s*$/gm.exec(e.stack)))
{
a.push("Call: " + m[1] + "; source: " + m[2] + "; line: " + m[3]);
}
window.alert(e.stack + "\n__\n" + a.length + "\n__\n" + a.join("\n"));
}

Separating function identifier from argument list, and source path from
source name, is left as an exercise to the reader.


PointedEars

Java script Dude

unread,
Jan 6, 2006, 2:12:10 PM1/6/06
to
Nice RegExp hack.

Thanks!

JsD

Thomas 'PointedEars' Lahn

unread,
Jan 5, 2006, 6:47:44 PM1/5/06
to
Thomas 'PointedEars' Lahn wrote:

> try
> {
> // don't declare x before
> y = x;
> }
> catch (e)
> {
> var m, a = [];
> while ((m = /^\s*(.*)@(.+):(\d+)\s*$/gm.exec(e.stack)))

As I see that the source is also optional, this should be changed to

while ((m = /^\s*(.*)@(.*):(\d+)\s*$/gm.exec(e.stack)))

> [...]

0 new messages