> > Hello internals! > > The RFC that proposes adding retry functionality to the > `try/catch/finally` block is now officially "under discussion". >
This feature seems like something that would be extremely useful. However, the proposed syntax for the number of retries for a block level seems to get me. I think what might actually be better from a functional standpoint is: try { doSomething() } catch (SomethingException $e) { retry 3; } catch (RetryMaximumExceeded $e) { $e->getOriginatingException(); } Forcing retry to only work on the keyword level and then providing a distinct exception when the retry has been exceeded. The issue obviously with the above is that you would need to be able to add the originating exception to it rather than bubbling up. What I like more about this, is that it makes it far more clear as per the rejected path and allows you to determine that you had to throw since the retries failed so many times. Often in many applications, you might retry a couple of times and then defer that action to be handled in the background at a later time. In addition, you may also still want to handle that exception to check certain criteria around the failure. For instance, it is often that libraries reuse the same exception but providing different codes and/or messages that you may want to check to see if it is retryable or add additional meta data to the response. I also think that the RFC should state that retry keyword MUST be used with a numeric number to prevent continuous loops. Eventually all loops must die and preventing this early on seems to be something that would be a good idea to handle. > > https://wiki.php.net/rfc/retry-keyword > > Voting will open on Monday, July 3rd, 2017 @ 9 am CDT. > > Voting will close on Monday, July 17th, 2017 @ 9 am CDT. > > Discuss amongst yourselves. :) > > Thanks, > Sammy Kaye Powers > sammyk.me > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >