Google 網路論壇不再支援新的 Usenet 貼文或訂閱項目,但過往內容仍可供查看。

parsing mozilla's Error stack property

瀏覽次數:2 次
跳到第一則未讀訊息

Java script Dude

未讀,
2006年1月5日 下午4:50:492006/1/5
收件者:
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

未讀,
2006年1月5日 下午6:14:502006/1/5
收件者:
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

未讀,
2006年1月6日 下午2:12:102006/1/6
收件者:
Nice RegExp hack.

Thanks!

JsD

Thomas 'PointedEars' Lahn

未讀,
2006年1月5日 下午6:47:442006/1/5
收件者:
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 則新訊息