Skip to content

Commit

Permalink
Improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mole99 committed Oct 1, 2024
1 parent a42687f commit e170819
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cace/parameter/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ def get_result(self, name: str):
if name in self.results_dict:
return self.results_dict[name]

warn(f'Could not find result {name}.')
return None

def cancel(self, no_cb):
Expand Down Expand Up @@ -431,6 +430,11 @@ def evaluate_result(self):
# For each named result in the spec
for named_result in self.param['spec']:

if not self.get_result(named_result):
err(f'No result "{named_result}" available.')
self.result_type = ResultType.ERROR
continue

# For each entry in the specs
for entry in ['minimum', 'typical', 'maximum']:

Expand Down Expand Up @@ -469,6 +473,8 @@ def evaluate_result(self):
else:
err(f'Unknown calculation type: {calculation}')
else:
err(f'Result "{named_result}" is empty.')
self.result_type = ResultType.ERROR
result = None

self.get_result(named_result).result[entry] = result
Expand Down
6 changes: 6 additions & 0 deletions cace/parameter/parameter_ngspice.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,12 @@ def __getattr__(self, attr):

for variable in script_variables:
if variable != None:
# Check for variable in results
if variable not in collated_values:
err(f'Variable "{variable}" not in results.')
self.result_type = ResultType.ERROR
return

# Extend the final result
self.get_result(variable).values.extend(
collated_values[variable]
Expand Down

0 comments on commit e170819

Please sign in to comment.