Created
July 25, 2014 13:38
-
-
Save harikt/d8f2afc634771f469a42 to your computer and use it in GitHub Desktop.
How to make the exception string without new line character ?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, traceback | |
def func1(): | |
try: | |
raise Exception | |
except: | |
# print (" %s " % sys.exc_info()[0]) | |
exc_type, exc_value, exc_traceback = sys.exc_info() | |
lines = traceback.format_exception(exc_type, exc_value, exc_traceback) | |
print ''.join(line.strip() + ' ' for line in lines) | |
print " list " | |
print traceback.extract_tb(exc_traceback, 3) | |
print " Something awesome " | |
print traceback.format_exc() | |
func1() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment