我试图捕捉一个没有引发的异常,只是记录了。有没有办法做到这一点?
def exampleFunction():
try:
x = 1 / 0
except Exception:
logging.exception('divide by 0 error here.')
try:
exampleFunction()
except <condition based on if logging.exception was called>
print('there was a divide by 0 error when I called exampleFunction()')
墨色风雨
Cats萌萌
相关分类