-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.py
More file actions
41 lines (35 loc) · 1.18 KB
/
errors.py
File metadata and controls
41 lines (35 loc) · 1.18 KB
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
33
34
35
36
37
38
39
40
41
import sys
class Errors:
def __init__(self):
self.error_found = False
self.errors = []
def is_error(self):
if len(self.errors) != 0:
self.error_found = True
return self.error_found
def print_error(self):
if self.is_error():
print("ERRORS")
for i in self.errors:
print("Type:", i.error_type)
print("Location:", i.error_location)
print("Error Message:", i.error_message)
print()
def append_error(self, error_type="MISC", error_message="", error_location="MISC"):
error = {
error_type: error_type,
error_message: error_message,
error_location: error_location,
}
self.errors.append(error)
if not self.error_found:
self.error_found = True
def print_last_error(self):
if self.is_error():
err = self.errors[-1]
print("Type:", err.error_type)
print("Location:", err.error_location)
print("Error Message:", err.error_message)
def kill(self):
self.print_error()
sys.exit("Found Errors, Terminating Code")