private function get_data($data) { foreach ($data as $key => $value) { $person = PersonFactory::create_person($value['object_type']); $person->get_data_from_array($value); $this->add($person); } }
<?php // errorMishandling.php require __DIR__ . '/infrastructure.php'; try { $person = PersonFactory::getPersonFromId($_GET['id']); } catch (Exception $e) { echo 'Exception caught<br>'; die; } try { $result = doSomethingToPerson($person); echo 'Process ran OK<br>'; } catch (Exception $e) { echo 'Exception caught<br>'; } catch (EngineException $e) { echo 'EngineException caught<br>'; } catch (TypeError $e) { echo 'TypeError caught<br>'; } catch (Throwable $t) { echo 'Throwable caught<br>'; } finally { echo 'In finally block<br>'; } echo 'After try/catch/finally<br>';