So, in this example, if, say, bar() throws a SomeException , the code
would then resume and execute baz() after the catch block.
Just presenting the idea here, no RFC actually , I'm collecting
thoughts and notices.
It seems like you want application specific flow control (caller
specific) when particular exceptions are raised. This is achievable
through goto, why not use that?
http://3v4l.org/HsdlD
<?php
class SomeException extends Exception {}
function foo() {
echo 'attempting 1' . PHP_EOL;
}
function bar($someCondition) {
echo 'attempting 2 with ' . $someCondition . PHP_EOL;
if ($someCondition == null) {
throw new SomeException('Foo foo fooey');
}
}
function baz() {
echo 'attempting 3' . PHP_EOL;
throw new Exception('Boo boo bar');
}
function fixupforbar(&$someCondition) {
$someCondition = 5;
}
/** main() **/
$someCondition = null;
try {
foo();
BAR: bar($someCondition);
baz();
} catch (SomeException $e) {
fixupforbar($someCondition);
goto BAR;
} catch (Exception $e) {
echo 'Exception caught: ' . $e->getMessage() . PHP_EOL;
} finally {
echo 'Cleaning up' . PHP_EOL;
}
-ralph
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php