Google Groups không còn hỗ trợ đăng ký sử dụng hoặc đăng nội dung mới trên Usenet. Bạn vẫn có thể xem nội dung cũ.

parsing mozilla's Error stack property

2 lượt xem
Chuyển tới thư đầu tiên chưa đọc

Java script Dude

chưa đọc,
16:50:49 5 thg 1, 20065/1/06
đến
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

chưa đọc,
18:14:50 5 thg 1, 20065/1/06
đến
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

chưa đọc,
14:12:10 6 thg 1, 20066/1/06
đến
Nice RegExp hack.

Thanks!

JsD

Thomas 'PointedEars' Lahn

chưa đọc,
18:47:44 5 thg 1, 20065/1/06
đến
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 tin nhắn mới