Catch various exceptions on the index
This commit is contained in:
parent
75052e58f3
commit
b670b16ca2
1 changed files with 13 additions and 2 deletions
11
index.php
11
index.php
|
@ -19,7 +19,11 @@ if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/index.ph
|
|||
}
|
||||
|
||||
if (is_file(__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.
|
||||
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());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue