Skip to content

Commit b1fc2be

Browse files
authored
Print traceback for internal command errors (#198)
Closes #196
1 parent 73b75c6 commit b1fc2be

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

spin/__main__.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import importlib.util
44
import os
55
import sys
6+
import textwrap
7+
import traceback
68

79
import click
810

@@ -152,8 +154,25 @@ def group(ctx):
152154

153155
try:
154156
group()
155-
except Exception as e:
156-
print(f"Error: {e}; aborting.", file=sys.stderr)
157+
except Exception:
158+
click.secho("\n" + traceback.format_exc(limit=-3), fg="red", file=sys.stderr)
159+
click.secho(
160+
textwrap.dedent(
161+
f"""\
162+
An internal error has occurred. Please file a bug report at
163+
164+
https://github.com/scientific-python/spin
165+
166+
including the above traceback and the following information:
167+
168+
spin: {__version__}, package: {proj_name}
169+
170+
Aborting."""
171+
),
172+
fg="red",
173+
bold=True,
174+
file=sys.stderr,
175+
)
157176
sys.exit(1)
158177

159178

0 commit comments

Comments
 (0)