Mein Beispiel:Wie behandelt man Exception innerhalb eines anderen try catch Blocks?
class CustomException extends \Exception {
}
class FirstClass {
function method() {
try {
$get = external();
if (!isset($get['ok'])) {
throw new CustomException;
}
return $get;
} catch (Exception $ex) {
echo 'ERROR1'; die();
}
}
}
class SecondClass {
function get() {
try {
$firstClass = new FirstClass();
$get = $firstClass->method();
} catch (CustomException $e) {
echo 'ERROR2'; die();
}
}
}
$secondClass = new SecondClass();
$secondClass->get();
Diese Rückkehr me "ERROR1", aber ich möchte "ERROR2" von Second erhalten.
In FirstClass-Block Versuch fangen sollte Fehler von external() -Methode behandeln.
Wie kann ich es machen?