← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #678681]: Sikuli 1.1.3: Is it possible to trap syntax errors?

 

Question #678681 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/678681

    Status: Needs information => Answered

RaiMan proposed the following answer:
IMHO no need to use try...except.

retcode = execfile(joinedname)

in case of no error retcode will be None

In was of any error, retcode will contain something like that:

[error] script [ syntaxControl ] stopped with error in line 6
[error] ZeroDivisionError ( integer division or modulo by zero )
[error] --- Traceback --- error source first
line: module ( function ) statement 
1: syntax (  <module> )     1/0
[error] --- Traceback --- end --------------

in this case the joined name script simply contains 
1/0

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.