ni / nimi-python

Python bindings for NI Modular Instrument drivers.
Other
112 stars 84 forks source link

Raise error if library not found, before attempting to load it #1992

Closed ni-jfitzger closed 1 year ago

ni-jfitzger commented 1 year ago

What does this Pull Request accomplish?

The code to load a DLL may change over time, leading to it returning different errors. This led to us returning a poor error when the driver runtime is not installed.

To improve our error behavior, raise a DriverNotInstalledError at the step where we look for the library, if it's not found. This happens before we attempt to load the library and since determining that the library wasn't found doesn't rely on getting a specific error, our behavior will be less likely to change.

Also add a test to cover this behavior.

List issues fixed by this Pull Request below, if any.

What testing has been done?

There's nothing OS-specific about _get_library_name(), so it should be okay that the unit tests only run on Linux.