From ee601e99107d1ee97933aeaeebf9d0aee24f9778 Mon Sep 17 00:00:00 2001 From: Shaun Crampton Date: Wed, 14 Oct 2015 14:38:39 +0100 Subject: Introduce EtcdWatchTimedOut exception. Suppress spammy error log when a watch times out and raise a dedicated exception instead. EtcdWatchTimedOut subclasses EtcdConnectionFailed for back-compatibility. Revs urllib3 dependency to 1.7.1, which split TimeoutError into ReadTimeoutError and ConnectionTimeoutError. --- src/etcd/__init__.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/etcd/__init__.py') diff --git a/src/etcd/__init__.py b/src/etcd/__init__.py index b532be6..2032be3 100644 --- a/src/etcd/__init__.py +++ b/src/etcd/__init__.py @@ -200,6 +200,13 @@ class EtcdConnectionFailed(EtcdException): self.cause = cause +class EtcdWatchTimedOut(EtcdConnectionFailed): + """ + A watch timed out without returning a result. + """ + pass + + class EtcdWatcherCleared(EtcdException): """ Watcher is cleared due to etcd recovery. -- cgit v1.2.3 From 1857e763de136f296700f07a58524c9f790206ce Mon Sep 17 00:00:00 2001 From: Giuseppe Lavagetto Date: Sat, 28 Nov 2015 16:48:36 +0100 Subject: Add error handling for ACLs (use and management) Also removed auth.py; in its current form it's wrong and unusable --- src/etcd/__init__.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/etcd/__init__.py') diff --git a/src/etcd/__init__.py b/src/etcd/__init__.py index 2032be3..f52852c 100644 --- a/src/etcd/__init__.py +++ b/src/etcd/__init__.py @@ -200,6 +200,13 @@ class EtcdConnectionFailed(EtcdException): self.cause = cause +class EtcdInsufficientPermissions(EtcdException): + """ + Request failed because of insufficient permissions. + """ + pass + + class EtcdWatchTimedOut(EtcdConnectionFailed): """ A watch timed out without returning a result. @@ -253,6 +260,7 @@ class EtcdError(object): 107: EtcdRootReadOnly, 108: EtcdDirNotEmpty, # 109: Non-public: existing peer addr. + 110: EtcdInsufficientPermissions, 200: EtcdValueError, 201: EtcdValueError, @@ -284,6 +292,13 @@ class EtcdError(object): message = payload.get("message") cause = payload.get("cause") msg = '{} : {}'.format(message, cause) + status = payload.get("status") + # Some general status handling, as + # not all endpoints return coherent error messages + if status == 404: + error_code = 100 + elif status == 401: + error_code = 110 exc = cls.error_exceptions.get(error_code, EtcdException) if issubclass(exc, EtcdException): raise exc(msg, payload) -- cgit v1.2.3