what to do if script fails code example

Example: what to do if script fails

In my experience, I will identify the failure,
o if it is this due to application error,
sync error, script issue or environment 
is down, first of all I analyze the result by
reproduce it through Jenkins run only the fail one,
o if it is due to synchronization issue, 
I will add extra time by using implicit, 
explicit and some custom expected
conditions,
o If it is script issue I will debugging 
(identify) my script and fix it, analyze the exceptions,
o if it is real defect then I will log defect.