fix: rethrow JSONDecodeError after printing the undecodable value as a warning

This commit is contained in:
ptrcnull 2024-06-12 12:09:58 +02:00
parent 35a27b7685
commit 4781e088a3
Signed by: ptrcnull
GPG key ID: 411F7B30801DD9CA

View file

@ -23,7 +23,11 @@ class CloudflareHandler(Handler):
env = os.environ.copy() env = os.environ.copy()
env['CF_API_TOKEN'] = self.secret env['CF_API_TOKEN'] = self.secret
res = subprocess.run(['flarectl', '--json'] + args, check=True, stdout=subprocess.PIPE, env=env) res = subprocess.run(['flarectl', '--json'] + args, check=True, stdout=subprocess.PIPE, env=env)
try:
return json.loads(res.stdout) return json.loads(res.stdout)
except json.decoder.JSONDecodeError as ex:
self.log.warning('could not decode as JSON: %s', res.stdout)
raise ex
def create(self, record_name: str, record_value: str) -> None: def create(self, record_name: str, record_value: str) -> None:
full_record_name = record_name + '.' + self.zone full_record_name = record_name + '.' + self.zone