Google Gruppi non supporta più i nuovi post o le nuove iscrizioni Usenet. I contenuti storici continuano a essere visibili.

parsing mozilla's Error stack property

2 visualizzazioni
Passa al primo messaggio da leggere

Java script Dude

da leggere,
5 gen 2006, 16:50:4905/01/06
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

Thomas 'PointedEars' Lahn

da leggere,
5 gen 2006, 18:14:5005/01/06
a
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

da leggere,
6 gen 2006, 14:12:1006/01/06
a
Nice RegExp hack.

Thanks!

JsD

Thomas 'PointedEars' Lahn

da leggere,
5 gen 2006, 18:47:4405/01/06
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)))

> [...]

0 nuovi messaggi