By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,009 Members | 1,643 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,009 IT Pros & Developers. It's quick & easy.

parsing mozilla's Error stack property

P: n/a
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

Jan 5 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Java script Dude wrote:
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.


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
Jan 5 '06 #2

P: n/a
Nice RegExp hack.

Thanks!

JsD

Jan 6 '06 #3

P: n/a
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)))
[...]

Jan 6 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.