浏览代码

fix(api): improve change tracker error verbosity

Peter Thomassen 5 年之前
父节点
当前提交
796578aeac
共有 2 个文件被更改,包括 3 次插入2 次删除
  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)