
185
5.5 例外処理
... raise ValueError('
')
... except Exception as e:
... raise #
元々の例外を再送出
...
>>> spam()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in spam
ValueError:
不正な値です
5.5.3
例外の連結
例外の処理中にも、さまざまな理由から、別の例外が発生する場合があります。
>>> def spam():
... try:
... raise ValueError('
')
... except Exception as e:
... 1/0
...
>>> spam()
Traceback (most recent call last):
File "<stdin>", line 3, in spam
ValueError:
不正な値です
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 5, in spam
ZeroDivisionError: division by ...