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

Exceptions are not re-raised #45

Open
omron93 opened this issue Dec 6, 2021 · 0 comments
Open

Exceptions are not re-raised #45

omron93 opened this issue Dec 6, 2021 · 0 comments

Comments

@omron93
Copy link

omron93 commented Dec 6, 2021

Inspecting the sros.py code I can see that in multiple places the exception is caught for logging the exception into log. But the exception is not re-raised, so it's logged but then the code continues in processing.

This is quite misleading and hard to properly integrate the sros driver into larger projects (the same applies to having prints in the driver which can't be "suppressed" from the application - the logging is configurable, the prints not).
So I can see issues like

Error in opening netconf connection : Could not open socket to edge3-uat.linx.net:830
Error in method get config : 'NoneType' object has no attribute 'get_config'
Traceback (most recent call last):
  File "/home/marek/.local/bin/pysros", line 33, in <module>
    sys.exit(load_entry_point('pysros==0.0.4', 'console_scripts', 'pysros')())
  File "/home/marek/.local/lib/python3.8/site-packages/pysros/command_line.py", line 17, in wrapper
    func()
  File "/home/marek/.local/lib/python3.8/site-packages/pysros/command_line.py", line 170, in main
    running.write(result['running'])
TypeError: 'NoneType' object is not subscriptable

The reason for the failure is that the device is unreachable, but TypeError: 'NoneType' object is not subscriptable is completely unrelated and very misleading.
That's even harder to debug when using the sros driver with projects like napalm-ansible because it doesn't show the printed command but just fails with 'NoneType' object has no attribute 'edit_config' :-)

Please re-raise the exceptions as that's the standard behaviour and the "application" should handle those issues not to have them suppressed in "library".

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