Skip to content

Instantly share code, notes, and snippets.

@titovanton
Created March 18, 2021 15:06
Show Gist options
  • Save titovanton/3092aadeb7c216980e90aa300ea6916d to your computer and use it in GitHub Desktop.
Save titovanton/3092aadeb7c216980e90aa300ea6916d to your computer and use it in GitHub Desktop.
import pdb
import traceback
class DebugOnError:
def __init__(self, suppress=False):
self.suppress = suppress
def __enter__(self):
return None
def __exit__(self, _type, _value, _traceback):
if _traceback:
traceback.print_exception(_type, _value, _traceback)
pdb.post_mortem(_traceback)
return self.suppress
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment