[tor-commits] [stem/master] InvalidRequest now inherits from ControllerError
atagar at torproject.org
atagar at torproject.org
Wed Jul 4 21:34:20 UTC 2012
commit 0db367a151dc75fde8a3a90fd273bda7ad9227ab
Author: Ravi Chandra Padmala <neenaoffline at gmail.com>
Date: Sat Jun 9 09:49:07 2012 +0530
InvalidRequest now inherits from ControllerError
Moved stem.response.InvalidRequest -> stem.socket.InvalidRequest and made it a subclass of stem.socket.ControllerError
---
stem/response/__init__.py | 7 +------
stem/response/getconf.py | 2 +-
stem/socket.py | 4 ++++
test/unit/response/getconf.py | 2 +-
4 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/stem/response/__init__.py b/stem/response/__init__.py
index ae3af4c..a9b69a3 100644
--- a/stem/response/__init__.py
+++ b/stem/response/__init__.py
@@ -60,7 +60,7 @@ def convert(response_type, message):
:raises:
* :class:`stem.socket.ProtocolError` the message isn't a proper response of that type
- * :class:`stem.response.InvalidRequest` the request was invalid
+ * :class:`stem.socket.InvalidRequest` the request was invalid
* TypeError if argument isn't a :class:`stem.response.ControlMessage` or response_type isn't supported
"""
@@ -413,8 +413,3 @@ def _get_quote_indeces(line, escaped):
return tuple(indices)
-class InvalidRequest(Exception):
- """
- Base Exception class for invalid requests
- """
- pass
diff --git a/stem/response/getconf.py b/stem/response/getconf.py
index 8dcd483..c1872cd 100644
--- a/stem/response/getconf.py
+++ b/stem/response/getconf.py
@@ -33,7 +33,7 @@ class GetConfResponse(stem.response.ControlMessage):
pass
if unrecognized_keywords:
- raise stem.response.InvalidRequest("GETCONF request contained unrecognized keywords: %s\n" \
+ raise stem.socket.InvalidRequest("GETCONF request contained unrecognized keywords: %s\n" \
% ', '.join(unrecognized_keywords))
else:
raise stem.socket.ProtocolError("GETCONF response contained a non-OK status code:\n%s" % self)
diff --git a/stem/socket.py b/stem/socket.py
index 1a14c82..258a7dc 100644
--- a/stem/socket.py
+++ b/stem/socket.py
@@ -28,6 +28,7 @@ as instances of the :class:`stem.response.ControlMessage` class.
ControllerError - Base exception raised when using the controller.
|- ProtocolError - Malformed socket data.
+ |- InvalidRequest - Invalid request parameters.
+- SocketError - Communication with the socket failed.
+- SocketClosed - Socket has been shut down.
"""
@@ -548,6 +549,9 @@ class ControllerError(Exception):
class ProtocolError(ControllerError):
"Malformed content from the control socket."
+class InvalidRequest(ControllerError):
+ "Base Exception class for invalid requests"
+
class SocketError(ControllerError):
"Error arose while communicating with the control socket."
diff --git a/test/unit/response/getconf.py b/test/unit/response/getconf.py
index ca75130..5dd8964 100644
--- a/test/unit/response/getconf.py
+++ b/test/unit/response/getconf.py
@@ -73,7 +73,7 @@ class TestGetConfResponse(unittest.TestCase):
"""
control_message = mocking.get_message(UNRECOGNIZED_KEY_RESPONSE)
- self.assertRaises(stem.response.InvalidRequest, stem.response.convert, "GETCONF", control_message)
+ self.assertRaises(stem.socket.InvalidRequest, stem.response.convert, "GETCONF", control_message)
def test_invalid_multiline_content(self):
"""
More information about the tor-commits
mailing list