import traceback
import logging
import textwrap
try:
whatever()
except Exception as e:
print(textwrap.indent(traceback.format_exc(), '\t'))
# logging.error(traceback.format_exc())
# Logs the error appropriately.
Traceback (most recent call last): File "<ipython-input-11-71725e6e6877>", line 6, in <module> whatever() NameError: name 'whatever' is not defined
try:
whatever()
try:
print('hi')
except Exception as e:
print(textwrap.indent(traceback.format_exc(), '\t'))
# logging.error(traceback.format_exc())
# Logs the error appropriately.
File "<ipython-input-14-816cfd102f4c>", line 3 try: ^ SyntaxError: invalid syntax
textwrap.indent('hey', '\t')
'\they'