Skip to content

Suppress verbose tracebacks by default, show only with -vv#852

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/cleaner-error-messages
Draft

Suppress verbose tracebacks by default, show only with -vv#852
Copilot wants to merge 3 commits intomainfrom
copilot/cleaner-error-messages

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 9, 2026

Describe your changes

Unhandled exceptions currently dump full Python stack traces, burying the actual error message in noise. This installs a custom sys.excepthook in the fre() entry point that shows only the error type and message at default/-v verbosity, with a hint to use -vv for the full traceback.

Before (default):

clone of FMSpid exited with status 128
Traceback (most recent call last):
  File "...", line 8, in <module>
    sys.exit(fre())
  ... (20+ lines of click internals) ...
subprocess.CalledProcessError: Command '...' returned non-zero exit status 128.

After (default):

CalledProcessError: Command '...' returned non-zero exit status 128.
(use 'fre -vv ...' for the full traceback)

After (fre -vv): full traceback, same as current behavior.

Changes:

  • fre/fre.py: Set sys.excepthook to a brief formatter when log_level > DEBUG. Updated -v help text.
  • fre/tests/test_fre_cli.py: Three subprocess-based tests covering default, -v, and -vv traceback behavior.
  • docs/tools.rst: Document traceback suppression under the -v[v] flag.

Issue ticket number and link (if applicable)

Checklist before requesting a review

  • I ran my code
  • I tried to make my code readable
  • I tried to comment my code
  • I wrote a new test, if applicable
  • I wrote new instructions/documentation, if applicable
  • I ran pytest and inspected it's output
  • I ran pylint and attempted to implement some of it's feedback
  • No print statements; all user-facing info uses logging module

Copilot AI linked an issue Apr 9, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits April 9, 2026 15:11
Install a custom sys.excepthook in the fre() entry point that suppresses
Python tracebacks at default and -v verbosity levels. At -vv (DEBUG), the
full traceback is shown. At lower levels, only the exception type and
message are printed, along with a hint to use 'fre -vv ...' for more
detail.

Closes #793

Agent-Logs-Url: https://github.com/NOAA-GFDL/fre-cli/sessions/d594a572-8566-467b-9a96-4b233d712582

Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor error messages for clarity Suppress verbose tracebacks by default, show only with -vv Apr 9, 2026
Copilot AI requested a review from ilaflott April 9, 2026 15:17
@ilaflott ilaflott requested review from uramirez8707 and removed request for ilaflott April 14, 2026 20:25
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 14, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.10%. Comparing base (836559e) to head (cf83c57).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
fre/fre.py 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #852      +/-   ##
==========================================
- Coverage   84.12%   84.10%   -0.03%     
==========================================
  Files          71       71              
  Lines        4944     4950       +6     
==========================================
+ Hits         4159     4163       +4     
- Misses        785      787       +2     
Flag Coverage Δ
unittests 84.10% <66.66%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
fre/fre.py 94.44% <66.66%> (-5.56%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 836559e...cf83c57. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cleaner Error messages

3 participants