error)) { $this->error = new Exception('Error'); $this->debug = false; } // Set proper HTTP status code http_response_code($this->error->getCode()); // For 404 errors, try to load custom error page via plugin if ($this->error->getCode() === 404) { $app = Factory::getApplication(); // Check if error404 plugin set a menu item ID if (isset($GLOBALS['error404_menu_item_id']) && $GLOBALS['error404_menu_item_id'] > 0) { try { // Boot the plugin and call its render method $plugin = $app->bootPlugin('error404', 'system'); if (method_exists($plugin, 'render404PageFromErrorDocument')) { $success = $plugin->render404PageFromErrorDocument( (int) $GLOBALS['error404_menu_item_id'], $this ); // If successful, include the normal template if ($success && isset($GLOBALS['error_page_component_output'])) { $templatePath = JPATH_THEMES . '/' . $app->getTemplate() . '/index.php'; if (file_exists($templatePath)) { include $templatePath; return; } } } } catch (Exception $e) { // Fall through to default error page } } } // For all other errors, use Joomla's default system error template $systemErrorTemplate = JPATH_THEMES . '/system/error.php'; if (file_exists($systemErrorTemplate)) { include $systemErrorTemplate; } else { // Fallback basic error display echo '
' . htmlspecialchars($this->error->getMessage(), ENT_QUOTES, 'UTF-8') . '
'; echo ''; }