2012-11-08 234 views
7

我运行轨道3应用程序中使用therubyracer和V8堆栈跟踪3

如果出现任何错误,该错误信息被通过电子邮件通过正常发送到我的内心一些javascript导轨3异常通知过程。

但是,我得到的错误信息非常含糊,堆栈跟踪不会进入JavaScript文件本身。这是可以理解的,但是很难调试。这里有一个例子:

V8::JSError: Cannot read property '0' of undefined 
backtrace: 

lib/libraryname.rb:32:in `function_that_calls_v8' 
lib/libraryname.rb:18:in `fetch_and_update' 
app/models/listing.rb:34:in `fetch' 

有没有一种方法,这样,当一个异常被抛出,这样我可以告诉哪一行的JavaScript内部borking我可以公开的JavaScript堆栈跟踪? (起码,得到行号)

+0

你有没有得到过这个解决方案? – andygeers

回答

0

我想你可以使用V8错误类,尝试做这个

begin 
    #normal V8 code 


rescue V8::Error => error 
    error.value #the JavaScript value passed to the `throw` statement 
    error.cause #the underlying error (if any) that triggered this error to be raised 
    error.javascript_backtrace #the complete JavaScript stack at the point this error was thrown 
    #use these values and send them to the exception system (however that happenS) 
end 

说实话,我不是这是否会工作,但给它试一试