Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For arguments given in wrong order, error message could be more helpful #106

Open
aawdls opened this issue Jul 9, 2019 · 0 comments
Open

Comments

@aawdls
Copy link
Contributor

aawdls commented Jul 9, 2019

I made a mistake in an element.get_value call, where I got the order of the arguments wrong. Pytac accepted my units constant as a choice of handle and gave the corresponding error. It would be nicer if it could notice my mistake and give a more useful message.

corrector = lattice.get_elements("HSTR")[5]
corrector.get_value("x_kick", pytac.ENG)



---------------------------------------------------------------------------
HandleException                           Traceback (most recent call last)
<ipython-input-20-2ba9c33239e9> in <module>()
      1 # Get a corrector magnet
      2 corrector = lattice.get_elements("HSTR")[5]
----> 3 corrector.get_value("x_kick", pytac.ENG)
      4 

/scratch/atip/pytac/pytac/element.pyc in get_value(self, field, handle, units, data_source, throw)
    221         try:
    222             return self._data_source_manager.get_value(field, handle, units,
--> 223                                                        data_source, throw)
    224         except DataSourceException:
    225             raise DataSourceException("No data source {0} on element {1}."

/scratch/atip/pytac/pytac/data_source.pyc in get_value(self, field, handle, units, data_source, throw)
    211         try:
    212             data_source = self._data_sources[data_source]
--> 213             value = data_source.get_value(field, handle, throw)
    214             return self._uc[field].convert(value, origin=data_source.units,
    215                                            target=units)

/scratch/atip/pytac/pytac/data_source.pyc in get_value(self, field, handle, throw)
    335         """
    336         try:
--> 337             return self._devices[field].get_value(handle, throw)
    338         except KeyError:
    339             raise FieldException("No field {0} on data source {1}."

/scratch/atip/pytac/pytac/device.pyc in get_value(self, handle, throw)
    177         else:
    178             raise HandleException("Device {0} has no {1} PV.".format(self.name,
--> 179                                                                      handle))
    180 
    181     def set_value(self, value, throw=True):

HandleException: Device SR01A-PC-HSTR-06 has no engineering PV.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant