use*_*003 11 django exception-handling
我正在尝试创建一个通用的错误处理程序,类似于Oracle中的"其他人".我可以找到的示例都涉及捕获特定的预期错误.
Try:
    some_function()
Except: #I don't know what error I'm getting
    show_me_error(type_of_error_and_message)
DrT*_*rsa 33
try:
    1/0
except Exception as e:
    print '%s (%s)' % (e.message, type(e))
>>> 
integer division or modulo by zero (<type 'exceptions.ZeroDivisionError'>)
这是非常有据可查的.
但也许你只需要Sentry?
小智 10
import traceback
try:
    some_function()
except Exception as e:
    trace_back = traceback.format_exc()
    message = str(e)+ " " + str(trace_back)
    print message
| 归档时间: | 
 | 
| 查看次数: | 37915 次 | 
| 最近记录: |