Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a debugging mode controlled by NEXTSTRAIN_DEBUG #208

Merged
merged 2 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion nextstrain/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from .argparse import HelpFormatter, register_commands, register_default_command
from .command import build, view, deploy, remote, shell, update, check_setup, login, logout, whoami, version, debugger
from .debug import DEBUGGING
from .errors import NextstrainCliError
from .util import warn
from .__version__ import __version__ # noqa: F401 (for re-export)
Expand All @@ -32,7 +33,10 @@ def run(args):
return opts.__command__.run(opts)

except NextstrainCliError as error:
warn(error)
if DEBUGGING:
traceback.print_exc()
else:
warn(error)
return 1

except AssertionError:
Expand Down
12 changes: 12 additions & 0 deletions nextstrain/cli/debug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""
Debug flags and utilities.

.. envvar:: NEXTSTRAIN_DEBUG

Set to a truthy value (e.g. 1) to print more information about (handled)
errors. For example, when this is not set or falsey, stack traces and
parent exceptions in an exception chain are omitted from handled errors.
"""
from os import environ

DEBUGGING = bool(environ.get("NEXTSTRAIN_DEBUG"))