Skip to content

Commit

Permalink
theory+likelihood: better error info for internal (or inherited)
Browse files Browse the repository at this point in the history
  • Loading branch information
JesusTorrado committed Feb 25, 2021
1 parent 30dc978 commit bb2a0da
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cobaya/theory.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,12 @@ def check_cache_and_compute(self, dependency_params=None, want_derived=False,
raise
except Exception as e:
if self.stop_at_error:
raise LoggedError(self.log, "Error at evaluation: %r", e)
if isinstance(e, LoggedError):
# Assume informative error message provided
raise LoggedError(self.log, "Error at evaluation: %r", e)
else:
self.log.error("Error at evaluation. See traceback below.")
raise
else:
self.log.debug(
"Ignored error at evaluation and assigned 0 likelihood "
Expand Down

2 comments on commit bb2a0da

@cmbant
Copy link
Collaborator

@cmbant cmbant commented on bb2a0da Feb 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there shouldn't be a "not" before isinstance(e, LoggedError): ?

@JesusTorrado
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally it's the other way around: if we are raising a LoggedError, we are assuming that we know what's happened and we are providing an informative message. Otherwise we should raise a different kind of error, and in that case print the traceback. I think what's wrong is the fix that I suggested for the other case. We don't need the traceback there, just the message ("get_testa NotImplemented in camb") so I'd be in favour of reverting that change there and instead trying to find out how we can show the relevant message. Let me give it a try.

Please sign in to comment.