Support custom 500 page when debug mode disabled and CMS module not present

This commit is contained in:
Luke Towers 2019-02-26 14:26:56 -06:00
parent 8f5ff1be5a
commit 7f3fb06945
3 changed files with 33 additions and 9 deletions

View File

@ -57,18 +57,22 @@ class ErrorHandler extends ErrorHandlerBase
return null;
}
$theme = Theme::getActiveTheme();
$router = new Router($theme);
if (class_exists(Theme::class) && in_array('Cms', Config::get('cms.loadModules', []))) {
$theme = Theme::getActiveTheme();
$router = new Router($theme);
// Use the default view if no "/error" URL is found.
if (!$router->findByUrl('/error')) {
return View::make('cms::error');
// Use the default view if no "/error" URL is found.
if (!$router->findByUrl('/error')) {
return View::make('cms::error');
}
// Route to the CMS error page.
$controller = new CmsController($theme);
$result = $controller->run('/error');
} else {
$result = View::make('system::error');
}
// Route to the CMS error page.
$controller = new CmsController($theme);
$result = $controller->run('/error');
// Extract content from response object
if ($result instanceof \Symfony\Component\HttpFoundation\Response) {
$result = $result->getContent();

View File

@ -447,6 +447,12 @@ return [
'invalid_path' => "Invalid file path specified: ':path'.",
'folder_size_items' => 'item(s)',
],
'page' => [
'custom_error' => [
'label' => 'Page error',
'help' => "We're sorry, but something went wrong and the page cannot be displayed."
],
],
'pagination' => [
'previous' => 'Previous',
'next' => 'Next',

View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="<?= App::getLocale() ?>">
<head>
<meta charset="utf-8">
<title><?= Lang::get('system::lang.page.custom_error.label') ?></title>
<link href="<?= Url::asset('/modules/system/assets/css/styles.css') ?>" rel="stylesheet">
</head>
<body>
<div class="container">
<h1><i class="icon-power-off warning"></i> <?= Lang::get('system::lang.page.custom_error.label') ?></h1>
<p class="lead"><?= Lang::get('system::lang.page.custom_error.help') ?></p>
</div>
</body>
</html>