From 19abd85b710682b326702e2290a30d084fb0af71 Mon Sep 17 00:00:00 2001 From: Neil Jerram Date: Tue, 17 Sep 2019 22:33:46 +0100 Subject: [PATCH] Fix exception signature I previously extended the Etcd3Exception constructor signature such that it was no longer possible for the derived exception types to construct with no args. This change makes that possible again, while still allowing an Etcd3Exception to be constructed with detail text as well as the traditional "Bad Request" message. --- etcd3gw/client.py | 2 +- etcd3gw/exceptions.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/etcd3gw/client.py b/etcd3gw/client.py index 7313783..9f2901a 100644 --- a/etcd3gw/client.py +++ b/etcd3gw/client.py @@ -83,7 +83,7 @@ def post(self, *args, **kwargs): if resp.status_code in _EXCEPTIONS_BY_CODE: raise _EXCEPTIONS_BY_CODE[resp.status_code](resp.reason) if resp.status_code != requests.codes['ok']: - raise exceptions.Etcd3Exception(resp.reason, resp.text) + raise exceptions.Etcd3Exception(resp.text, resp.reason) except requests.exceptions.Timeout as ex: raise exceptions.ConnectionTimeoutError(six.text_type(ex)) except requests.exceptions.ConnectionError as ex: diff --git a/etcd3gw/exceptions.py b/etcd3gw/exceptions.py index 00ac8f5..cd9134a 100644 --- a/etcd3gw/exceptions.py +++ b/etcd3gw/exceptions.py @@ -12,8 +12,8 @@ class Etcd3Exception(Exception): - def __init__(self, msg, detail_text=None): - super(Etcd3Exception, self).__init__(msg) + def __init__(self, detail_text=None, *args): + super(Etcd3Exception, self).__init__(*args) self.detail_text = detail_text