Skip to content
This repository has been archived by the owner on Sep 17, 2019. It is now read-only.

More exceptions #248

Merged
merged 3 commits into from
May 31, 2017
Merged

More exceptions #248

merged 3 commits into from
May 31, 2017

Conversation

mirceaulinic
Copy link
Member

@mirceaulinic mirceaulinic commented May 30, 2017

Define new exception ConnectionClosedException as per #247

Add the exceptions proposed in #218

@mirceaulinic mirceaulinic added this to the 0.24.0 milestone May 30, 2017
@mirceaulinic mirceaulinic changed the title New exception: ConnectionClosedException More exceptions May 30, 2017
@@ -22,6 +22,35 @@ class ModuleImportError(Exception):


class ConnectionException(Exception):
'''
Unable to connect to the network device.
Raised by the ``open`` method.
Copy link
Member

@dbarrosop dbarrosop May 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This last sentence is not accurate. For two reasons;

  1. childs of this class will be thrown in other places, which means you can actually catch this exception in other methods.
  2. It kind of implies this is the only exception that is going to be thrown by the open method while the truth is that it would be nice if its childs were raised instead.


class ConnectTimeoutError(ConnectionException):
'''
Connection to the network device takes too long.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe mention timeout value can be tweaked with the timeout argument. Mostly to indicate there is a correlation.


class ConnectionClosedException(ConnectionException):
'''
The network device closed the connection.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would reword this and use "dropped' instead unless we are expecting to raise this exception if the server ends the TCP socket. My guess is we will be raising this if the connection is silently dropped by a firewall or the server.

Copy link
Member

@dbarrosop dbarrosop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. Just a few concerns regarding how things are worded :)

@mirceaulinic
Copy link
Member Author

@dbarrosop I've pushed some changes: b3b5c9b, feel free to suggest more improvements if anything still doesn't sound good.

@ktbyers
Copy link
Contributor

ktbyers commented May 30, 2017

In SSH you can also have the SSH channel closed by remote end (currently raises an EOFError in Netmiko). In this case the TCP connection is still open, but you are unable to communicate.

I think this should probably fall into this ConnectionClosedException as you would need to treat it the same way in practice (i.e. re-open a new connection).

@mirceaulinic
Copy link
Member Author

Yes, that was my understanding too @ktbyers. Would you suggest including this explanation in the exception docsting?

@ktbyers
Copy link
Contributor

ktbyers commented May 30, 2017

I think we might want to include that in the docstring (i.e. 'or SSH channel closing').

@dbarrosop
Copy link
Member

dbarrosop commented May 31, 2017

We don't really need to be super explicit. Most of the time people will just want to know the connection was dropped due to inactivity (regardless of who or how) and just try to reconnect. My point is that a single ConnectionDroppedException and then different messages for logging purposes should probably be enough. I can't imagine someone treating a timeout because a firewall dropped a flow being treated different than ssh closing the channel.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants