So you have some Python code in a try-catch, and you want the typical Python stacktrace (aka traceback, aka backtrace) in a way you can manipulate?
Here are some ways to handle it:
import traceback
import logging
try:
stuff()
except Exception:
# Just print traceback
print "something went wrong, here is …