我正在使用python3.8,Docker版本 19.03.13,构建 4484c46d9d 3.8
version: '3.8'
services:
web:
build: .
command: python /code/manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- 8000:8000
Run Code Online (Sandbox Code Playgroud) 我已经定义了一个自定义 Exception 对象,并想获取异常的行号。
class FlowException(Exception):
pass
def something():
print 2/3
print 1/2
print 2/0
try:
something()
except Exception as e:
raise FlowException("Process Exception", e)
Run Code Online (Sandbox Code Playgroud)
现在,如果 something() 中有异常,它会抛出 FlowException 但它没有给我确切的行号,我如何从 FlowException 中获取行号(即;它在 2/0 执行时失败)?
这是输出:--
raise FlowException("Process Exception", e)
__main__.FlowException: ('Process Exception', ZeroDivisionError('integer division or modulo by zero',))
[Finished in 0.4s with exit code 1]
Run Code Online (Sandbox Code Playgroud)