Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 17360

What does above exception points to in exception info thrown?

$
0
0

The simplest built-in exception as below:

>>> 1/0Traceback (most recent call last):  File "<stdin>", line 1, in <module>ZeroDivisionError: division by zero

Throw exception info ,then whole press is done.

Define function f1 and not to define myException:

def f1():    try:        print(1/0)    except:        raise myException('my exception')

Call f1():

>>> f1()Traceback (most recent call last):  File "<stdin>", line 3, in f1ZeroDivisionError: division by zeroDuring handling of the above exception, another exception occurred:Traceback (most recent call last):  File "<stdin>", line 1, in <module>  File "<stdin>", line 5, in f1NameError: name 'myException' is not defined

When the info

Traceback (most recent call last):  File "<stdin>", line 3, in f1ZeroDivisionError: division by zero

thrown out,exception of print(1/0) is handled as we have seen that in the beginning.
Why the statement in the middle line is During handling of the above exception, another exception occurred: ,instead of After handling of the above exception, another exception occurred:?
What is above exception in the statement During handling of the above exception?It points to try ... except structure in f1 ,instead of exception resulted by 1/0?
If above exception points to exception resulted by 1/0,then After handling of the above exception, another exception occurred is better to describe all the exceptions here!


Viewing all articles
Browse latest Browse all 17360

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>