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

Chained exception does not show cause message #1024

Closed
parched opened this issue Aug 21, 2022 · 1 comment · Fixed by #1057
Closed

Chained exception does not show cause message #1024

parched opened this issue Aug 21, 2022 · 1 comment · Fixed by #1057
Labels
enhancement New feature or request

Comments

@parched
Copy link

parched commented Aug 21, 2022

I'm not really sure if this is a bug or a feature request or if this should be raised in vscode-python instead but it appears related to #391

Environment data

  • debugpy version: 1.6.3
  • OS and version: Windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.10
  • Using VS Code or Visual Studio: VS Code

Actual behavior

When a chained exception is caught it doesn't show the cause message, even though it shows the stack trace and says it was the cause.

image

Expected behavior

I think it should show:

  1. The cause message
  2. The cause stack trace
  3. The above exception was the direct cause of the following exception:

  4. The message
  5. The stack trace

Alternatively 1 and 2 could be swapped as well as 4 and 5 swapped which would match what I see in the output:

Traceback (most recent call last):
  File "c:\Users\james.duley\dev\design-library-2\py-lib\src\holmes_design\junk.py", line 3, in <module>
    print(empty_dict["key"])
KeyError: 'key'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\james.duley\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main    return _run_code(code, main_globals, None,
  File "C:\Users\james.duley\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "c:\Users\james.duley\.vscode\extensions\ms-python.python-2022.13.12301015\pythonFiles\lib\python\debugpy\__main__.py", line 39, in <module>
    cli.main()
  File "c:\Users\james.duley\.vscode\extensions\ms-python.python-2022.13.12301015\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 430, in main
    run()
  File "c:\Users\james.duley\.vscode\extensions\ms-python.python-2022.13.12301015\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 284, in run_file
    runpy.run_path(target, run_name="__main__")
  File "c:\Users\james.duley\.vscode\extensions\ms-python.python-2022.13.12301015\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 321, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "c:\Users\james.duley\.vscode\extensions\ms-python.python-2022.13.12301015\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 135, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "c:\Users\james.duley\.vscode\extensions\ms-python.python-2022.13.12301015\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 124, in _run_code
    exec(code, run_globals)
  File "c:\Users\james.duley\dev\design-library-2\py-lib\src\holmes_design\junk.py", line 5, in <module>
    raise Exception("Something went wrong") from e
Exception: Something went wrong

Steps to reproduce:

  1. Run this code in debug mode in VS Code with "Uncaught Exceptions" breakpoint enabled
empty_dict = {}
try:
    print(empty_dict["key"])
except KeyError as e:
    raise Exception("Something went wrong") from e
@int19h int19h added the enhancement New feature or request label Aug 30, 2022
@fabioz
Copy link
Collaborator

fabioz commented Sep 16, 2022

I'll take a look at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants