forked from K0lb3/UnityPy
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexceptions.py
More file actions
23 lines (18 loc) · 763 Bytes
/
Copy pathexceptions.py
File metadata and controls
23 lines (18 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from . import config
MAX_SANE = 0xFFFFF
class TypeTreeError(Exception):
def __init__(self, message, nodes):
super().__init__(message)
self.nodes = nodes
def sanity_check(value_name: str, value: int, max_value: int=MAX_SANE) -> None:
if config.DEBUG and (value > max_value):
raise ValueIsTooBig(f"{value_name} length", value)
class ValueIsTooBig(Exception):
def __init__(self, variable_name, value):
sep_value = f"{value:,}"#.replace(',', ' ')
super().__init__(f"{variable_name} value = {sep_value} is unrealistically big")
self.value = value
class ReadingPastObject(Exception):
def __init__(self, obj):
super().__init__(f"read data past {obj} length")
self.value = obj