aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2014-02-13 20:31:10 +0100
committerChristian Weiske <cweiske@cweiske.de>2014-02-13 20:31:10 +0100
commitfd8a57c746babfc215e0d9be0e13259c3f5e1150 (patch)
tree830a1b100d8818f9f49844175aae51c10e28b58c
parentcbf951471e3a3bb3f7ddd0f9ca2d07241aba756d (diff)
downloadbdrem-fd8a57c746babfc215e0d9be0e13259c3f5e1150.tar.gz
bdrem-fd8a57c746babfc215e0d9be0e13259c3f5e1150.zip
catch exceptions
-rw-r--r--src/bdrem/UserInterface.php32
1 files changed, 19 insertions, 13 deletions
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()