gpt4 book ai didi

python - 获取错误详细信息,例如 'openerp application error details'

转载 作者:太空宇宙 更新时间:2023-11-03 17:26:39 29 4
gpt4 key购买 nike

我正在尝试在 openerp 中创建错误处理,我使用“try - except”方法:

try:
bla bla bla
...

except Exception,e:
raise osv.except_osv('Error!','%s'%e)

我可以获得作为 openerp 应用程序错误详细信息(例如:包含错误、错误行号等的 file.py)完成的错误消息吗?

像这个:

Traceback (most recent call last):
File "/opt/openerp/server/openerp/netsvc.py", line 293, in dispatch_rpc
result = ExportService.getService(service_name).dispatch(method, params)
File "/opt/openerp/server/openerp/service/web_services.py", line 654, in dispatch
res = fn(db, uid, *params)
File "/opt/openerp/server/openerp/service/web_services.py", line 760, in exp_report_get
return self._check_report(report_id)
File "/opt/openerp/server/openerp/service/web_services.py", line 738, in _check_report
netsvc.abort_response(exc, exc.message, 'warning', exc.traceback)
File "/opt/openerp/server/openerp/netsvc.py", line 72, in abort_response
raise openerp.osv.osv.except_osv(description, details)
except_osv: (u'report.faxing.fax', (<type 'exceptions.KeyError'>, KeyError(u'report.faxing.fax',), <traceback object at 0xb271d20c>))

最佳答案

解决了!

我只需要在我的代码中使用回溯:

import traceback

try:
bla bla bla
...

except Exception, e:
raise osv.except_osv('Error!','%s'%traceback.format_exc())

还有咒语,我会得到我需要的..

希望它对你们也有用..:)

关于python - 获取错误详细信息,例如 'openerp application error details',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32471351/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com