Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

README.md

Exception Handling: Custom, Context Suppression, Edge Cases

Custom Exception

class MyError(Exception):
    pass

Context Suppression

try:
    1/0
except ZeroDivisionError as e:
    raise ValueError('Bad math') from None

return in finally (Edge Case)

def test():
    try:
        raise Exception('fail')
    finally:
        return 'suppressed!'
print(test())  # 'suppressed!'