Skip to content

Commit 09393e7

Browse files
committed
ObjectReader - allow error passthrough
1 parent 9a87a40 commit 09393e7

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

UnityPy/files/ObjectReader.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,20 @@ def Position(self, pos):
157157
def reset(self):
158158
self.reader.Position = self.byte_start
159159

160-
def read(self):
160+
def read(self, return_typetree_on_error: bool=True):
161161
cls = getattr(classes, self.type.name, None)
162162

163163
obj = None
164164
if cls:
165165
try:
166166
obj = cls(self)
167167
except Exception as e:
168-
print(e)
168+
if return_typetree_on_error:
169+
print(f"Error during the parsing of object {self.path_id}")
170+
print(e)
171+
print("Returning the typetree")
172+
else:
173+
raise e
169174
if not obj:
170175
typetree = self.read_typetree()
171176
if typetree:

0 commit comments

Comments
 (0)