Browse Source

feat(api): generalize PdnsException for non-JSON errors

Peter Thomassen 8 years ago
parent
commit
bb5ced496f
1 changed files with 4 additions and 1 deletions
  1. 4 1
      api/desecapi/exceptions.py

+ 4 - 1
api/desecapi/exceptions.py

@@ -6,4 +6,7 @@ class PdnsException(APIException):
 
     def __init__(self, response):
         self.status_code = response.status_code
-        self.detail = json.loads(response.text)['error']
+        try:
+            self.detail = json.loads(response.text)['error']
+        except:
+            self.detail = response.text