rfc:retry-keyword

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
rfc:retry-keyword [2017/06/19 13:46] – Change title sammykrfc:retry-keyword [2017/06/19 18:34] – remove words "visual debt" sammyk
Line 135: Line 135:
 </code> </code>
  
-This is arguably the cleanest option for retrying but is blanketed with the negative stigma of using a ''goto''.+While this is arguably the cleanest option, it still requires the developer to define and manage label which over several refactors might gradually move further away from the top of the ''try'' lineThis implementation also makes it easy to accidentally execute any code after the label & before the ''try'' for each retry which is not entirely obvious at first glance. 
 + 
 +<code php> 
 +$maxTries = 5; 
 + 
 +retryTheThing: 
 + 
 +someCodeIDoNotWantToRetry(); 
 + 
 +try { 
 +    somethingSketchy(); 
 +} catch (RecoverableException $e) { 
 +    if (--$maxTries > 0) { 
 +        goto retryTheThing; 
 +    } 
 +    die('Tried a bunch but failed.'); 
 +
 +</code>
  
 ==== Use Retry ==== ==== Use Retry ====
rfc/retry-keyword.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1