从 web2py 获取每个错误的堆栈跟踪
我通过 jsonrpc 将 web2py 与 javascript 客户端结合使用。我注意到,对于某些错误,web2py 会分配一个票证并创建一个堆栈跟踪,然后我可以查看并确切地知道错误发生的位置(就像在普通 python 中一样)。在其他情况下,web2py 只是通过 jsonrpc 响应向我发送错误,而不指定触发它的文件、函数或行,我只看到以下信息:
'message': u'IndexError: list index out of range', ' code': 100, 'data': None
由于我不知道这个错误发生在哪里,所以我确实没有好的方法来调试它。我可以告诉 web2py 为每个错误开一张票,或者至少通过 jsonrpc 提供更多信息吗?
I'm using web2py in combination with a javascript client via jsonrpc. I noticed that for some errors web2py assigns a ticket and creates a stack trace which I can then look at and know exactly where the error occured (just like in normal python). In other cases web2py simply sends me the error via jsonrpc response, without specifying the file, function, or line that triggered it, and I simply see the following info:
'message': u'IndexError: list index out of range', 'code': 100, 'data': None
Since I have no idea where this error occured, there is really no good way for me to debug it. Can I tell web2py to open a ticket for every error, or at least provide more information through jsonrpc?
在 web2py gluon/tools.py 模块中,查找函数“serve_jsonrpc”。异常处理是捕获错误并将其重新打包为您从客户端看到的消息的地方。您应该能够在 except 子句中放置一些断点并找到问题
In the web2py gluon/tools.py module, look for the function "serve_jsonrpc". The exception handling there is the place that the error is being caught and repackaged as the message you see from the client. You should be able to put some breakpoints in the except clauses and find the issue