diff --git a/index.php b/index.php index 0b7772c..a62d032 100644 --- a/index.php +++ b/index.php @@ -19,7 +19,11 @@ if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/index.ph } if (is_file(__DIR__ . '/config/config.yml')) { - Config::setFile(__DIR__ . '/config/config.yml'); + try { + Config::setFile(__DIR__ . '/config/config.yml'); + } catch (Exception $e) { + die('Could not load config file: ' . $e->getMessage()); + } } // Create app. @@ -50,7 +54,11 @@ $container['locale'] = LocaleManager::getInstance(); $app->add(new LocaleMiddleware($container)); // Smarty. -$container['view'] = ViewFactory::create($container); +try { + $container['view'] = ViewFactory::create($container); +} catch (SmartyException $e) { + die('Could not load Smarty: ' . $e->getMessage()); +} // Controllers. $frontController = new FrontController($container); @@ -105,4 +113,7 @@ try { $app->run(); } catch (SmartyException $e) { die('Smarty could not compile the template file: ' . $e->getMessage()); +} catch (Throwable $e) { + // Last resort if the error has not been caught by the error handler for some reason. + die('Error when starting the app: ' . $e->getMessage()); }