Browse Source

fix(api): improve change tracker error verbosity

Peter Thomassen 5 years ago
parent
commit
796578aeac
2 changed files with 3 additions and 2 deletions
  1. 2 1
      api/desecapi/exceptions.py
  2. 1 1
      api/desecapi/pdns_change_tracker.py

+ 2 - 1
api/desecapi/exceptions.py

@@ -25,7 +25,8 @@ class PDNSValidationError(ValidationError):
 class PDNSException(APIException):
     def __init__(self, response=None):
         self.response = response
-        return super().__init__(f'pdns response code: {response.status_code}, pdns response body: {response.text}')
+        detail = f'pdns response code: {response.status_code}, body: {response.text}' if response is not None else None
+        return super().__init__(detail)
 
 
 class ConcurrencyException(APIException):

+ 1 - 1
api/desecapi/pdns_change_tracker.py

@@ -267,7 +267,7 @@ class PDNSChangeTracker:
                 raise e
             except Exception as e:
                 self.transaction.__exit__(type(e), e, e.__traceback__)
-                exc = ValueError(f'For changes {list(map(str, changes))}, {type(e)} occured when applying {change}')
+                exc = ValueError(f'For changes {list(map(str, changes))}, {type(e)} occurred during {change}: {str(e)}')
                 raise exc from e
 
         self.transaction.__exit__(None, None, None)