clarified source of an error message #1086
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
in the put method to the EpicsSignal class, there is a check to be sure that the signal can be written to, i.e. that self.write_access is true. that error message results in an unhelpful traceback in that it provides no information identifying the PV triggering the message. in the case of a deeply nested signal, this error message is unilluminating. this commit adds self.name to the error message.
This is, in my opinion, an example of a common anti-pattern in ophyd. There are many error messages that do a poor job identifying the prima causa of the error, simply resulting in a lengthy traceback that is hard to parse for someone not well versed in ophyd's internals.
In my case, I was, with a lot of poking and prodding, able to identify the source of the error. Had the error message included the name (as in
self.name
) of the ophyd object, it would have been a much shorter path to identifying the problem.My solution was to simply append
self.name
to the error message. Not a perfect solution, but it would at least point the human doing the debugging in the right direction.I have a hard time believing this is simply a problem for someone like me, who is writing beamline code without also having a deep understanding of Ophyd. I cannot believe that a context-free error message could be helpful even to Ophyd's main developers.
Were I king of the world (or at least of DSSI), I would call for a full audit of ophyd to find all examples of context-free messages like this one. I would then call for agreement on a convention for making better, more helpful, better contextualized error messages.
All right! Rant is finished. Thanks for humoring me 😁