
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Rethrow Python Exception with New Type
In Python 3.x, the code is subject to exception chaining and we get the output as follows
C:/Users/TutorialsPoint1/~.py Traceback (most recent call last): File "C:/Users/TutorialsPoint1/~.py", line 2, in <module> 1/0 ZeroDivisionError: division by zero
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "C:/Users/TutorialsPoint1/~.py", line 4, in <module> raise ValueError ( "Sweet n Sour grapes" ) from e ValueError: Sweet n Sour grapes
Advertisements