From: Christian Weiske Date: Thu, 13 Feb 2014 19:31:10 +0000 (+0100) Subject: catch exceptions X-Git-Tag: v0.5.0~37 X-Git-Url: https://git.cweiske.de/bdrem.git/commitdiff_plain/fd8a57c746babfc215e0d9be0e13259c3f5e1150?ds=inline catch exceptions --- diff --git a/src/bdrem/UserInterface.php b/src/bdrem/UserInterface.php index 5fb028b..da5e9a3 100644 --- a/src/bdrem/UserInterface.php +++ b/src/bdrem/UserInterface.php @@ -7,21 +7,27 @@ abstract class UserInterface public function run() { - $this->config = new Config(); - $this->config->load(); - $this->config->date = date('Y-m-d'); - setlocale(LC_TIME, $this->config->locale); - $source = $this->config->loadSource(); + try { + $this->config = new Config(); + $this->config->load(); + $this->config->date = date('Y-m-d'); + setlocale(LC_TIME, $this->config->locale); + $source = $this->config->loadSource(); - $parser = $this->loadParameters(); - $this->parseParameters($parser); + $parser = $this->loadParameters(); + $this->parseParameters($parser); - $arEvents = $source->getEvents( - $this->config->date, - $this->config->daysPrev, $this->config->daysNext - ); - usort($arEvents, '\\bdrem\\Event::compare'); - $this->render($arEvents); + $arEvents = $source->getEvents( + $this->config->date, + $this->config->daysPrev, $this->config->daysNext + ); + usort($arEvents, '\\bdrem\\Event::compare'); + $this->render($arEvents); + } catch (\Exception $e) { + $this->preRenderParameterError(); + echo 'Exception: ' . $e->getCode() . ' ' . $e->getMessage() . "\n"; + exit(1); + } } protected function loadParameters()