SAE Teensy ECU
IIT SAE Microcontroller programming
Loading...
Searching...
No Matches
error.py
1"""Error related items"""
2
3
4class ScriptException(RuntimeError):
5 """Base Exception for this script"""
6
7
9 """Exception thrown when there are no more values that can be allocated to a type"""
10
11 def __init__(self, message):
12 super().__init__(message.strip(), "No more allocatable values to range")
13
14
16 """Exception thrown when obtaining a mapped pair results in mismatched values"""
17
18 def __init__(self, message):
19 super().__init__(message.strip(), "Resulting matched pair do not match in value")
20
21
23 """Exception thrown when a TAG is blank"""
24
25 def __init__(self, message):
26 super().__init__(message.strip(), "TAG literal string cannot be blank")
27
28
30 """Exception thrown when a TAG definition is malformed"""
31
32 def __init__(self, message):
33 super().__init__(message.strip(), "Implicit, single char or number definition of a LOG_TAG type")
34
35
37 """Exception thrown when a Log call is malformed"""
38
39 def __init__(self, message):
40 super().__init__(message.strip(), "Implicit string or number inside a call to Log")
41
42
43def error_to_string(error: Exception) -> Exception | str:
44 """Split exception into string if it is a ScriptException, else, return the exception
45
46 Args:
47 error (Exception): Exception to interpret
48
49 Returns:
50 Exception | str: Result
51 """
52 if issubclass(type(error), ScriptException):
53 return error.args[1] + "\n\t" + error.args[0]
54 else:
55 return error
Exception thrown when a TAG is blank.
Definition error.py:22
Exception thrown when a Log call is malformed.
Definition error.py:36
Exception thrown when a TAG definition is malformed.
Definition error.py:29
Exception thrown when there are no more values that can be allocated to a type.
Definition error.py:8
Base Exception for this script.
Definition error.py:4
Exception thrown when obtaining a mapped pair results in mismatched values.
Definition error.py:15
Exception|str error_to_string(Exception error)
Split exception into string if it is a ScriptException, else, return the exception.
Definition error.py:43