-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
32 lines (25 loc) · 1.12 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from dataclasses import dataclass
from Exception7Wheel import Exception7Wheel
from Car import Car
def make_car(drive, wheels , color='gold'):
# make car using attributes provided
try:
car = Car(drive, wheels, color)
print('car made successfully' , car)
except ValueError as v:
print('ValueError raised:', v)
except TypeError as t:
print('TypeError raised: ', t)
except Exception7Wheel as e:
print('No 7 wheel cars allowed!!! : ', e)
def main():
make_car('manual', 7, 'red') # will raise exception , custom Exception7Wheel
make_car('manual', '1a', 'yellow') # will raise exception , type error
make_car('manual', 12, 'blue') # will raise exception , value error
make_car('manual', 1, 'blue') # will raise exception , value error
make_car('manual', 1, 1234) # will raise exception , type error
make_car('auto', 4, 'grey') # will make a valid car
make_car('auto', 3.0, 'purple') # will make a valid car
make_car('auto', 5) # will make a valid car, default gold
if __name__ == '__main__':
main()