Currently, I am trying to implement some exception handling class as like the Python in-built exception class. My Question is how python decide or choose which exception is occurred,
for example
Example 1 : (Integer/0) is always **ZeroDivisionError** Exception.
Example 2 : 'x' + 1 is always **TypeError** Exception.
How python catch that without using any Try and Except block.
For me i have to put my code inside some Try Block then put some Exception Name, which may not always be right because my Exception can hide ZeroDivision Exception as below :
>>> try:
... 1 / 0
... except Exception as e:
... raise Exception (e)
...
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
Exception: integer division or modulo by zero
>>>
In my above code message is right but the exception name is wrong. So, someone please explain me how to write exception class and how to raise the right exception.
Thanks in adv.