sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #18647
Re: [Question #230510]: Printing the exception information in a catch block
Question #230510 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/230510
Mark Weisler posted a new comment:
The working script below illustrates some of how sys.exc_info works.
# script: sys.exc_info explorer
# Mark Weisler
# 11 June 2013
# our goal is to create an error condition, save error to a variable or a database
# Sikuli version X-1.0rc3 on OS X 10.6.8
try:
f = open('sometestfile2.txt', 'r') # make sure this file does not exist to trigger an error, which we want to do
f.close() # just in case the file did exist
except:
# some code maybe here
print "Got an exception:", sys.exc_info()[0], " --- saying:", sys.exc_info()[1]
print "0 is: ", sys.exc_info()[0]
print "1 is: ", sys.exc_info()[1]
ErrMsg = sys.exc_info()[1]
print "ErrMsg is: ", ErrMsg # could be logged or stored in a database
print "Finishing execution..."
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.