From: Raghuram D. <ra...@sy...> - 2006-06-28 17:29:33
|
I use a function like: def get_excinfo_str(): (exc_type, exc_value, exc_traceback) = sys.exc_info() formatted_excinfo = traceback.format_exception(exc_type, exc_value, exc_traceback) excinfo_str = string.join(formatted_excinfo) del exc_type del exc_value del exc_traceback return(excinfo_str) and call this from exception handling code. Raghu. Jeff Emanuel wrote: > sys.exc_info returns a tuple containing the > exception class, exception instance, and > a traceback object. You can generate > a string like that printed from the exc > info. > > import sys > ei=None > try: > doSomethingBad() > except: > ei=sys.exc_info() > > > Another option would be to implement an > excepthook function that replaces stderr > before calling the original excepthook. > The replaced stderr would capture the > stream output to a string. > > > > Dong, Ming wrote: >> Hi, >> >> Usually the exception message is printed out on the stdout such as >> Traceback (innermost last): >> File "./ACC/acclog.py", line 15, in ? >> NameError: existingProps >> >> Can the exception message be retrieved in jython code as a string? It >> will be greatly appreciated if you can give me a hand. >> >> Thanks a lot. >> >> Ming Dong >> >> Using Tomcat but need to do more? Need to support web services, security? >> Get stuff done quickly with pre-integrated technology to make your job easier >> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >> _______________________________________________ >> Jython-users mailing list >> Jyt...@li... >> https://lists.sourceforge.net/lists/listinfo/jython-users > > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > |