Skip to content

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

@aawdls

Description

@aawdls

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.


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions