Exceptions
Instro-specific errors inherit fromInstroError.
FeatureNotSupportedError
FeatureNotSupportedError (a subclass of InstroError) is raised by a concrete driver to declare that the connected instrument genuinely lacks a capability. For example, the BK9115 power supply has no overcurrent protection or remote sense, so its driver raises FeatureNotSupportedError for those methods.
InstroError, except InstroError catches it.
NotImplementedError
NotImplementedError is the Python builtin, not an InstroError. Each <Category>DriverBase declares its optional methods to raise NotImplementedError by default, and a driver overrides only the ones its instrument supports. Calling an optional method on a driver that has not overridden it therefore raises NotImplementedError: the capability is part of the category contract, but this driver does not implement it.
Because NotImplementedError is a builtin, except InstroError does not catch it.
Which one will I catch?
It depends on the driver behind the HAL:- A driver that explicitly declares a feature absent raises
FeatureNotSupportedError. - A driver that has simply not overridden an optional base method raises
NotImplementedError.
FeatureNotSupportedError when the hardware lacks the feature, and leave the inherited NotImplementedError in place for optional methods that are not implemented yet.