Ver código fonte

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

Peter Thomassen 8 anos atrás
pai
commit
bb5ced496f
1 arquivos alterados com 4 adições e 1 exclusões
  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