Nondiscriminatory error handling in the raiseorpush context manager masks errors not related to parsing and validation.
For example, in parsers/pywrjsonparser.py changing lines 141-143 from the original code:
with component_exc_capture("metadata") as cc:
self.metadata = PywrMetadata(self.src["metadata"])
cc.capture_warnings(self.metadata)
to
with component_exc_capture("metadata") as cc:
self.metadata = PywrMetadata(self.src["metadata"])
cc.capture_warnings("some other variable")
will not generate an exception.
To fix, update the __exit__ dunder method in lines 34-42 in utils .py to:
def __exit__(self, exc_type, exc_obj, exc_tb):
if isinstance(exc_obj, WNTREPANETTypeValidationErrorBundle):
for error in exc_obj.errors:
# Raise on warning implies raise on error
if self.raise_warning or self.raise_error:
raise error from None
self.dest.errors[self.component].append(error)
elif exc_obj is not None:
raise(exc_obj) from exc_obj
return not self.raise_warning
Nondiscriminatory error handling in the
raiseorpushcontext manager masks errors not related to parsing and validation.For example, in
parsers/pywrjsonparser.pychanging lines 141-143 from the original code:to
will not generate an exception.
To fix, update the
__exit__dunder method in lines 34-42 in utils .py to: