|
Posted by Richard Levasseur on 11/29/13 11:52
flamer die.spam@hotmail.com wrote:
> ImOk wrote:
>
> > I just have a question about trapping and retrying errors especially
> > file locking or database locks or duplicate key errors.
> >
> > Is there a way after you trap an error to retry the same line that
> > cause the error?
> >
> > In many other languages you have the option of rertying certain errors.
> > In effect, its like a return to the exact same line. You can then retry
> > certain # of times and then produce an error if it keeps failing.
>
> All I can think of is to use a loop
> while $result == null
> if ($retries > '3') { //do stuff $retries++ }
>
> or you can kill the script on error then reload the page
> header:$php_self?retries=$retries
>
> meh.. there is a way.. somehow.
>
> Flamer.
PHP5 doesn't have that feature, though i'd love to have that for some
situations, also.
I think c# has this feature, not sure though.
The best you could do is to nest a try/catch block within a loop and
use a control flag.
while($retry < 5) {
try{ .... } catch{$retry++; ... }
}
Navigation:
[Reply to this message]
|