Skip to content

Commit 58b47ed

Browse files
committed
Added lesson 19
1 parent a90f743 commit 58b47ed

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

β€ŽREADME.mdβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,4 @@
7575
- πŸ”— [Chapter 16 - Student Challenge](https://github.com/gitdagray/python-course/tree/main/lesson16)
7676
- πŸ”— [Chapter 17 - Lambda & Higher Order Functions](https://github.com/gitdagray/python-course/tree/main/lesson17)
7777
- πŸ”— [Chapter 18 - Classes, Objects, Inheritance & Polymorphism](https://github.com/gitdagray/python-course/tree/main/lesson18)
78+
- πŸ”— [Chapter 19 - Errors & Exception Handling](https://github.com/gitdagray/python-course/tree/main/lesson19)

β€Žlesson19/exceptions.pyβ€Ž

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class JustNotCoolError(Exception):
2+
pass
3+
4+
5+
x = 2
6+
try:
7+
raise JustNotCoolError("This just isn't cool, man.")
8+
# raise Exception("I'm a custom exception!")
9+
# print(x / 0)
10+
# if not type(x) is str:
11+
# raise TypeError("Only strings are allowed.")
12+
except NameError:
13+
print('NameError means something is probably undefined.')
14+
except ZeroDivisionError:
15+
print('Please do not divide by zero.')
16+
except Exception as error:
17+
print(error)
18+
else:
19+
print('No errors!')
20+
finally:
21+
print("I'm going to print with or without an error.")

0 commit comments

Comments
Β (0)