-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexceptions.py
64 lines (45 loc) · 2.11 KB
/
exceptions.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
AirSchedule Exceptions
2020
This file holds all the exceptions that AirSchedule throws
Typically in response to a misconfigured .scn file
"""
# If the create_simObject() can't determine a certain line of the scn file
# it will raise a MalformedScnException that points to the problem
class MalformedScnException(Exception):
def __init__(self, context, line):
self.context = context
self.line = line
self.message = "\n\n" + "".join(x + "\n" for x in self.context) + "\n" + str(self.context[self.line]) + " <--"
def __str__(self):
return self.message
# Raised if the parser can't find the object required to resolve a reference
class ObjectNotFoundException(Exception):
def __init__(self, object_type, object_name):
self.message = "\n\nCould not find type '%s' named '%s'\nWas the wrong type provided or the object not defined?" % (
object_type, object_name)
def __str__(self):
return self.message
# This can be thrown when trying to convert a time string in the scn file into a datetime object
class TimeNotISOException(Exception):
def __init__(self, time):
self.message = "\n\nThe time '%s' could not be parsed, is it in ISO 8601?" % time
def __str__(self):
return self.message
# A generic error when a variable in the scn file isn't what it's supposed to be
class BadFormatException(Exception):
def __init__(self, problem):
self.message = "\n\nThe data '%s' could not be parsed" % problem
def __str__(self):
return self.message
# This is raised by the parser if it fines two objects with the same type and name, which would break the simulator
class ObjectDefinedTwiceException(Exception):
def __init__(self, temp_object):
self.message = "\n\nThe object '%s %s' is defined twice" % (temp_object.object_type, temp_object.object_name)
def __str__(self):
return self.message
class NoScenarioFoundException(Exception):
def __init__(self):
self.message = "\n\nNo object with type 'scenario' could be found. One must be defined"
def __str__(self):
return self.message