diff --git a/modules/system/classes/ErrorHandler.php b/modules/system/classes/ErrorHandler.php index 327e56669..e0e02b7f7 100644 --- a/modules/system/classes/ErrorHandler.php +++ b/modules/system/classes/ErrorHandler.php @@ -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(); diff --git a/modules/system/lang/en/lang.php b/modules/system/lang/en/lang.php index 7f5c2a040..161b7ff2d 100644 --- a/modules/system/lang/en/lang.php +++ b/modules/system/lang/en/lang.php @@ -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', diff --git a/modules/system/views/error.php b/modules/system/views/error.php new file mode 100644 index 000000000..4a2aafd37 --- /dev/null +++ b/modules/system/views/error.php @@ -0,0 +1,14 @@ + + + + + <?= Lang::get('system::lang.page.custom_error.label') ?> + + + +
+

+

+
+ +