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

do not show full traceback by default #490

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
21 changes: 19 additions & 2 deletions src/fromager/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

TERSE_LOG_FMT = "%(message)s"
VERBOSE_LOG_FMT = "%(levelname)s:%(name)s:%(lineno)d: %(message)s"
_DEBUG = False

try:
external_commands.detect_network_isolation()
Expand All @@ -37,6 +38,12 @@
is_flag=True,
help="report more detail to the console",
)
@click.option(
"--debug",
default=False,
is_flag=True,
help="report full tracebacks to the console",
)
@click.option(
"--log-file",
type=clickext.ClickPath(),
Expand Down Expand Up @@ -131,6 +138,7 @@
def main(
ctx: click.Context,
verbose: bool,
debug: bool,
log_file: pathlib.Path,
error_log_file: pathlib.Path,
sdists_repo: pathlib.Path,
Expand All @@ -146,6 +154,10 @@ def main(
jobs: int | None,
network_isolation: bool,
) -> None:
# Save the debug flag so invoke_main() can use it.
global _DEBUG
_DEBUG = debug

# Set the overall logger level to debug and allow the handlers to filter
# messages at their own level.
logging.getLogger().setLevel(logging.DEBUG)
Expand Down Expand Up @@ -226,8 +238,13 @@ def invoke_main() -> None:
try:
main(auto_envvar_prefix="FROMAGER")
except Exception as err:
logger.exception(err)
raise
logger.debug(
err,
exc_info=True,
) # log the full traceback details to the debug log file, if any
logger.error(f"ERROR: {err}")
if _DEBUG:
raise


if __name__ == "__main__":
Expand Down
5 changes: 4 additions & 1 deletion src/fromager/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ def resolve_from_provider(
) -> tuple[str, Version]:
reporter: resolvelib.BaseReporter = resolvelib.BaseReporter()
rslvr: resolvelib.Resolver = resolvelib.Resolver(provider, reporter)
result = rslvr.resolve([req])
try:
result = rslvr.resolve([req])
except resolvelib.resolvers.exceptions.ResolutionImpossible as err:
raise ValueError(f"Unable to resolve {req}") from err
# resolvelib actually just returns one candidate per requirement.
# result.mapping is map from an identifier to its resolved candidate
candidate: Candidate
Expand Down
Loading