Explorar o código

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

Peter Thomassen %!s(int64=8) %!d(string=hai) anos
pai
achega
bb5ced496f
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  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