Browse Source

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

Peter Thomassen 8 năm trước cách đây
mục cha
commit
bb5ced496f
1 tập tin đã thay đổi với 4 bổ sung1 xóa
  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