Skip to content

Commit

Permalink
tool: Make exception handling more uniform
Browse files Browse the repository at this point in the history
  • Loading branch information
Spindel committed Apr 18, 2024
1 parent 4ac2fde commit 9c2b79d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions caramel/scripts/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,10 @@ def cmdline():
return args


def error_out(message):
def error_out(message, exc=None):
print(message)
if exc is not None:
print(str(exc))
sys.exit(1)


Expand Down Expand Up @@ -185,8 +187,8 @@ def csr_resign(ca, lifetime_short, lifetime_long, backdate):
with concurrent.futures.ThreadPoolExecutor(max_workers=16) as executor:
try:
csrlist = models.CSR.refreshable()
except Exception as ex:
error_out(f"Not found or some other error {ex}")
except Exception as exc:
error_out("Not found or some other error", exc=exc)
futures = (
executor.submit(refresh, csr, ca, lifetime_short, lifetime_long, backdate)
for csr in csrlist
Expand Down Expand Up @@ -216,7 +218,7 @@ def main():
try:
ca_cert_path, ca_key_path = config.get_ca_cert_key_path(args, settings)
except ValueError as error:
error_out(str(error))
error_out("Error reading ca data", exc=error)

ca = models.SigningCert.from_files(ca_cert_path, ca_key_path)

Expand Down

0 comments on commit 9c2b79d

Please sign in to comment.