You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
by defining the same LJMError class in the module where it is used, there exists a chicken/egg problem where the LJMError cannot be used to catch exception when importing LJM library.
For example:
try:
from labjack import ljm
except labjack.ljm.ljm.LJMError as exception:
raise LabjackLibraryNotInstalled from exception
cannot work because the LJMError is defined in the same module. A better practice is to seperate the exception class into it's own module that only depends on Python standard library, this ensures Labjack package exceptions can be used for module imports that wrap library code, just as labjack-ljm-python wraps the LJM library that is required to be installed.
Another issue is that the _loadLibrary() function catches the LJMError exception, prints the error, then returns None. Why? If the python package doesn't work without the LJM library, then it shouldn't handle the exception, it should just raise it and let the calling module handle the exception.
I had this same issue. I attempted a quick solution in #19 to fix this but haven't gotten any responses. Either way, #19 has a hacky workaround for any others reading this...
Sorry for not replying earlier and thank you for bringing up this issue. We are currently working on T8 release tasks. This is on our list of issues to look into soon.
by defining the same
LJMError
class in the module where it is used, there exists a chicken/egg problem where the LJMError cannot be used to catch exception when importing LJM library.For example:
cannot work because the LJMError is defined in the same module. A better practice is to seperate the exception class into it's own module that only depends on Python standard library, this ensures Labjack package exceptions can be used for module imports that wrap library code, just as
labjack-ljm-python
wraps the LJM library that is required to be installed.Another issue is that the
_loadLibrary()
function catches the LJMError exception, prints the error, then returns None. Why? If the python package doesn't work without the LJM library, then it shouldn't handle the exception, it should just raise it and let the calling module handle the exception.Please remove from
_loadLibrary()
:The text was updated successfully, but these errors were encountered: