Well - the issue is that apparently exceptions "just don't work this way". I solved the problem like this, hopefully it helps someone:
Code:
abstract class xGrandparent {
protected
$propertySettingExceptions = array()
;
public function __construct( $params = array() ){
foreach( $params as $k => $v ){
if( property_exists($this, $k) ){
$this->$k = $v;
} else {
try {
switch($k){
case 'e':
throw new Exception('exception e', 111);
break;
case 'f':
throw new Exception('exception f', 222);
break;
}
} catch (Exception $e){
$this->propertySettingExceptions[] = $e;
}
}
}
}
}
abstract class xParent extends xGrandparent {
protected
$c,
$d
;
public function __construct( $params = array() ){
parent::__construct( $params );
if( sizeof($exceptions = &$this->propertySettingExceptions) ){
foreach( $exceptions as $k => $exception ){
switch( $exception->getCode() ){
case 222:
echo "*** parent caught exception \n";
unset($exceptions[$k]);
break;
}
}
}
}
}
class xChild extends xParent {
protected
$a,
$b
;
public function __construct( $params = array() ){
parent::__construct( $params );
if( sizeof($exceptions = &$this->propertySettingExceptions) ){
foreach( $exceptions as $k => $exception ){
switch( $exception->getCode() ){
case 111:
echo "*** child caught exception \n";
unset($exceptions[$k]);
break;
}
}
}
}
}
$test = new xChild(array(
'a' => 'a val',
'c' => 'c val',
'e' => 'e val',
'f' => 'f val',
'b' => 'b val',
'd' => 'd val',
));
var_dump( $test );
Output:
*** parent caught exception
*** child caught exception
object(xChild)#1 (5) {
["a:protected"]=>
string(5) "a val"
["b:protected"]=>
string(5) "b val"
["c:protected"]=>
string(5) "c val"
["d:protected"]=>
string(5) "d val"
["propertySettingExceptions:protected"]=>
array(0) {
}
}