Clearer exceptions caused by constraint evaluation
This commit is contained in:
parent
043f44d163
commit
64708cb8d0
1 changed files with 8 additions and 3 deletions
|
|
@ -409,7 +409,6 @@ class Conformance:
|
||||||
}, # globals
|
}, # globals
|
||||||
loc # locals
|
loc # locals
|
||||||
)
|
)
|
||||||
# print('result =', result)
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def check_constraints(self):
|
def check_constraints(self):
|
||||||
|
|
@ -439,7 +438,10 @@ class Conformance:
|
||||||
for obj_name, obj_id in instances:
|
for obj_name, obj_id in instances:
|
||||||
description = f"Local constraint of \"{type_name}\" in \"{obj_name}\""
|
description = f"Local constraint of \"{type_name}\" in \"{obj_name}\""
|
||||||
# print(description)
|
# print(description)
|
||||||
|
try:
|
||||||
result = self.evaluate_constraint(code, this=obj_id)
|
result = self.evaluate_constraint(code, this=obj_id)
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception(f"Context of above error = {description}") from e
|
||||||
check_result(result, description)
|
check_result(result, description)
|
||||||
|
|
||||||
# global constraints
|
# global constraints
|
||||||
|
|
@ -457,8 +459,11 @@ class Conformance:
|
||||||
for tm_name in glob_constraints:
|
for tm_name in glob_constraints:
|
||||||
code = get_code(tm_name)
|
code = get_code(tm_name)
|
||||||
if code != None:
|
if code != None:
|
||||||
result = self.evaluate_constraint(code, model=self.model)
|
|
||||||
description = f"Global constraint \"{tm_name}\""
|
description = f"Global constraint \"{tm_name}\""
|
||||||
|
try:
|
||||||
|
result = self.evaluate_constraint(code, model=self.model)
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception(f"Context of above error = {description}") from e
|
||||||
check_result(result, description)
|
check_result(result, description)
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue