Skip to content

Post mortem debugging of the inner exception in exception chain #1042

@jjyyxx

Description

@jjyyxx

As is suggested in Pdb go to a frame in exception within exception, calling pdb.post_mortem on the __context__ of a chained exception gives a chance to debug the inner exception, and this could be nested. A minimal snippet would be

def fail():
  raise Exception(1)

try:
  try:
    fail()
  except Exception as e:
    raise Exception(2) from e
except Exception as e:
  import pdb
  # pdb.post_mortem(e.__traceback__)
  pdb.post_mortem(e.__context__.__traceback__)

But in vscode, I did not find a way to debug the inner exception from the raise Exception(2) from e line. I wonder whether this feature could be implemented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions