Skip to content

Commit

Permalink
Improve error reporting in codesigning scripts
Browse files Browse the repository at this point in the history
- Fix a missing f-string.
- Always print traceback on exceptions.
- Print traceback to stderr.
  • Loading branch information
lopopolo committed Sep 4, 2022
1 parent f6d8c1c commit db57e98
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions gpg_sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def main(args):

for artifact in artifacts:
if not artifact.is_file():
print("Error: {artifact} does not exist", file=sys.stderr)
print(f"Error: artifact file {artifact} does not exist", file=sys.stderr)
return 1

if len(artifacts) > 1:
Expand Down Expand Up @@ -191,10 +191,11 @@ def main(args):
\tReturn Code: {e.returncode}""",
file=sys.stderr,
)
print(traceback.format_exc(), file=sys.stderr)
return e.returncode
except Exception as e:
print(f"Error: {e}", file=sys.stderr)
print(traceback.format_exc())
print(traceback.format_exc(), file=sys.stderr)
return 1


Expand Down
9 changes: 7 additions & 2 deletions macos_sign_and_notarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,11 @@ def main(args):

for binary in binaries:
if not binary.is_file():
print("Error: {binary} does not exist", file=sys.stderr)
print(f"Error: binary file {binary} does not exist", file=sys.stderr)
return 1
for resource in resources:
if not resource.is_file():
print(f"Error: resource file {resource} does not exist", file=sys.stderr)
return 1

try:
Expand Down Expand Up @@ -765,10 +769,11 @@ def main(args):
\tReturn Code: {e.returncode}""",
file=sys.stderr,
)
print(traceback.format_exc(), file=sys.stderr)
return e.returncode
except Exception as e:
print(f"Error: {e}", file=sys.stderr)
print(traceback.format_exc())
print(traceback.format_exc(), file=sys.stderr)
return 1
finally:
# Purge keychain.
Expand Down

0 comments on commit db57e98

Please sign in to comment.