{"id":20180737,"url":"https://github.com/webfiori/err","last_synced_at":"2026-03-02T13:02:13.908Z","repository":{"id":40255266,"uuid":"492068989","full_name":"WebFiori/err","owner":"WebFiori","description":"A library for handling PHP errors and exceptions in a better way.","archived":false,"fork":false,"pushed_at":"2024-06-26T21:05:02.000Z","size":46,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-17T11:18:18.475Z","etag":null,"topics":["error-handling","error-reporting","hacktoberfest","php","webfiori"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WebFiori.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://paypal.me/IbrahimBinAlshikh","https://www.buymeacoffee.com/ibrahimdev"],"ko_fi":"ibrahimdev"}},"created_at":"2022-05-13T23:50:31.000Z","updated_at":"2024-06-26T21:03:40.000Z","dependencies_parsed_at":"2024-11-14T07:03:23.571Z","dependency_job_id":null,"html_url":"https://github.com/WebFiori/err","commit_stats":{"total_commits":32,"total_committers":2,"mean_commits":16.0,"dds":0.03125,"last_synced_commit":"0d4a6faaf28d7165e68998de1d333fecc31fd548"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebFiori%2Ferr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebFiori%2Ferr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebFiori%2Ferr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebFiori%2Ferr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WebFiori","download_url":"https://codeload.github.com/WebFiori/err/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240271521,"owners_count":19774859,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["error-handling","error-reporting","hacktoberfest","php","webfiori"],"created_at":"2024-11-14T02:32:40.083Z","updated_at":"2026-03-02T13:02:13.898Z","avatar_url":"https://github.com/WebFiori.png","language":"PHP","funding_links":["https://paypal.me/IbrahimBinAlshikh","https://www.buymeacoffee.com/ibrahimdev","https://ko-fi.com/ibrahimdev"],"categories":[],"sub_categories":[],"readme":"# WebFiori Error Handler\r\n\r\nA comprehensive, secure, and production-ready PHP library for handling errors and exceptions with advanced security features, CLI/HTTP awareness, memory management, and enterprise-grade reliability.\r\n\r\n\u003cp align=\"center\"\u003e\r\n  \u003ca target=\"_blank\" href=\"https://github.com/WebFiori/err/actions/workflows/php83.yaml\"\u003e\r\n    \u003cimg src=\"https://github.com/WebFiori/err/actions/workflows/php83.yaml/badge.svg?branch=main\"\u003e\r\n  \u003c/a\u003e\r\n  \u003ca href=\"https://sonarcloud.io/dashboard?id=WebFiori_err\"\u003e\r\n      \u003cimg src=\"https://sonarcloud.io/api/project_badges/measure?project=WebFiori_err\u0026metric=alert_status\" /\u003e\r\n  \u003c/a\u003e\r\n  \u003ca href=\"https://packagist.org/packages/webfiori/err\"\u003e\r\n    \u003cimg src=\"https://img.shields.io/packagist/dt/webfiori/err?color=light-green\"\u003e\r\n  \u003c/a\u003e\r\n\u003c/p\u003e\r\n\r\n## Supported PHP Versions\r\n\r\n|                                                                                       Build Status                                                                                       |\r\n|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|\r\n| \u003ca target=\"_blank\" href=\"https://github.com/WebFiori/err/actions/workflows/php81.yaml\"\u003e\u003cimg src=\"https://github.com/WebFiori/err/actions/workflows/php81.yaml/badge.svg?branch=main\"\u003e\u003c/a\u003e  |\r\n| \u003ca target=\"_blank\" href=\"https://github.com/WebFiori/err/actions/workflows/php82.yaml\"\u003e\u003cimg src=\"https://github.com/WebFiori/err/actions/workflows/php82.yaml/badge.svg?branch=main\"\u003e\u003c/a\u003e  |\r\n| \u003ca target=\"_blank\" href=\"https://github.com/WebFiori/err/actions/workflows/php83.yaml\"\u003e\u003cimg src=\"https://github.com/WebFiori/err/actions/workflows/php83.yaml/badge.svg?branch=main\"\u003e\u003c/a\u003e  |\r\n| \u003ca target=\"_blank\" href=\"https://github.com/WebFiori/err/actions/workflows/php84.yaml\"\u003e\u003cimg src=\"https://github.com/WebFiori/err/actions/workflows/php84.yaml/badge.svg?branch=main\"\u003e\u003c/a\u003e  |\r\n\r\n## Features\r\n\r\n* **🛡️ Security-First Design**: Built-in output sanitization, secure configuration management, and production-ready security features\r\n* **🔄 Comprehensive Error Handling**: Converts all PHP errors to exceptions with advanced filtering and sanitization\r\n* **🧠 Memory Management**: Advanced memory optimization with cleanup mechanisms, performance caching, and leak prevention\r\n* **⚡ Performance Optimized**: TraceEntry caching, memory threshold monitoring, and garbage collection integration\r\n* **🎯 Flexible Handler System**: Object-oriented abstraction with priority-based handler registration\r\n* **🌍 Environment-Aware**: Automatic environment detection with development and production presets\n* **🔧 Null Safety**: Robust null handling prevents TypeErrors in edge cases\n* **📊 Comprehensive Testing**: 92 tests with 100% pass rate ensuring reliability\r\n\r\n## Installation\r\n\r\nInstall via Composer:\r\n\r\n```bash\r\ncomposer require webfiori/err\r\n```\r\n\r\nOr add to your `composer.json`:\r\n\r\n```json\r\n{\r\n    \"require\": {\r\n        \"webfiori/err\": \"^2.0\"\r\n    }\r\n}\r\n```\r\n\r\n## Quick Start\r\n\r\n### Basic Usage\r\n\r\n```php\r\n\u003c?php\r\nrequire_once 'vendor/autoload.php';\r\n\r\nuse WebFiori\\Error\\Handler;\r\n\r\n// The handler system starts automatically when first accessed\r\n// Register the default handler (this happens automatically)\r\nHandler::registerHandler(new \\WebFiori\\Error\\DefaultHandler());\r\n\r\n// Your application code - errors will be caught automatically\r\nthrow new Exception('Something went wrong!');\r\n```\r\n\r\n### Custom Handler\r\n\r\n```php\r\n\u003c?php\r\nuse WebFiori\\Error\\AbstractHandler;\r\nuse WebFiori\\Error\\Handler;\r\n\r\nclass MyCustomHandler extends AbstractHandler {\r\n    public function __construct() {\r\n        parent::__construct();\r\n        $this-\u003esetName('My Custom Handler');\r\n        $this-\u003esetPriority(100);\r\n    }\r\n\r\n    public function handle(): void {\r\n        // Get sanitized exception information using built-in methods\r\n        $message = $this-\u003egetMessage(); // Already sanitized\r\n        $location = $this-\u003egetClass() . ' line ' . $this-\u003egetLine();\r\n        \r\n        // Output using secure output method\r\n        $this-\u003esecureOutput(\"ERROR: {$message}\\n\");\r\n        $this-\u003esecureOutput(\"Location: {$location}\\n\");\r\n    }\r\n\r\n    public function isActive(): bool {\r\n        return true;\r\n    }\r\n\r\n    public function isShutdownHandler(): bool {\r\n        return false;\r\n    }\r\n}\r\n\r\n// Register and the system will use it automatically\r\nHandler::registerHandler(new MyCustomHandler());\r\n```\r\n\r\n## Detailed Usage Guide\r\n\r\n### Handler Registration\r\n\r\nThe library supports multiple handlers with priority-based execution:\r\n\r\n```php\r\nuse WebFiori\\Error\\Handler;\r\nuse WebFiori\\Error\\DefaultHandler;\r\n\r\n// Register multiple handlers\r\nHandler::registerHandler(new ProductionHandler(), 100);  // Highest priority\r\nHandler::registerHandler(new LoggingHandler(), 50);      // Medium priority  \r\nHandler::registerHandler(new DefaultHandler(), 10);      // Lowest priority\r\n\r\n// The system starts automatically when handlers are registered\r\n```\r\n\r\n### Environment-Aware Configuration\r\n\r\nThe library automatically detects CLI vs HTTP environments and formats output appropriately:\r\n\r\n```php\r\nuse WebFiori\\Error\\Config\\HandlerConfig;\r\nuse WebFiori\\Error\\Handler;\r\n\r\n// Production configuration\r\n$config = HandlerConfig::createProductionConfig();\r\n\r\n// Development configuration  \r\n$config = HandlerConfig::createDevelopmentConfig();\r\n\r\n// Custom configuration\r\n$config = new HandlerConfig();\r\n$config-\u003esetErrorReporting(E_ALL)\r\n       -\u003esetDisplayErrors(false)\r\n       -\u003esetModifyGlobalSettings(true);\r\n\r\n// Apply configuration\r\nHandler::setConfig($config);\r\n```\r\n\r\n### Security Features\r\n\r\n#### Output Sanitization\r\n\r\n```php\r\nuse WebFiori\\Error\\AbstractHandler;\r\n\r\nclass SecureHandler extends AbstractHandler {\r\n    public function handle(): void {\r\n        // Automatically sanitized methods\r\n        $safeMessage = $this-\u003egetMessage(); // Already sanitized\r\n        $safeClass = $this-\u003egetClass(); // Already sanitized\r\n        \r\n        // Use secure output method\r\n        $this-\u003esecureOutput(\"Error: {$safeMessage}\");\r\n    }\r\n}\r\n```\r\n\r\n#### Security Configuration\r\n\r\n```php\r\nuse WebFiori\\Error\\Security\\SecurityConfig;\r\n\r\n// Create security config for different environments\r\n$devConfig = new SecurityConfig('development');   // Shows full details\r\n$prodConfig = new SecurityConfig('production');   // Minimal safe output\r\n$stagingConfig = new SecurityConfig('staging');   // Balanced approach\r\n\r\n// Custom security settings\r\n$customConfig = new SecurityConfig('custom');\r\n// Note: SecurityConfig uses internal methods for configuration\r\n```\r\n\r\n### Memory Management\r\n\r\nFor long-running processes and high-traffic applications:\r\n\r\n```php\r\nuse WebFiori\\Error\\Handler;\r\nuse WebFiori\\Error\\Config\\HandlerConfig;\r\n\r\n// Enable automatic memory management\r\n$config = new HandlerConfig();\r\n$config-\u003esetModifyGlobalSettings(true);\r\n\r\nHandler::setConfig($config);\r\n\r\n// Manual memory operations\r\nHandler::cleanupMemory();\r\n\r\n// Monitor memory usage\r\n$stats = Handler::getMemoryStats();\r\necho \"Current: \" . number_format($stats['current']) . \" bytes\\n\";\r\necho \"Peak: \" . number_format($stats['peak']) . \" bytes\\n\";\r\n```\r\n\r\n### Infinite Loop Protection\r\n\r\nPrevent handler execution cycles:\r\n\r\n```php\r\nuse WebFiori\\Error\\Config\\HandlerConfig;\r\nuse WebFiori\\Error\\Handler;\r\n\r\n$config = new HandlerConfig();\r\n$config-\u003esetModifyGlobalSettings(true);\r\n\r\nHandler::setConfig($config);\r\n\r\n// Set maximum handler executions\r\nHandler::setMaxHandlerExecutions(3); // Max 3 handler executions per request\r\n```\r\n\r\n### Logging Integration\r\n\r\nThe library integrates with PHP's error logging system:\r\n\r\n```php\r\nuse WebFiori\\Error\\AbstractHandler;\r\n\r\nclass LoggingHandler extends AbstractHandler {\r\n    public function handle(): void {\r\n        // Secure logging with automatic sanitization\r\n        $this-\u003esecureLog('Exception occurred', [\r\n            'class' =\u003e $this-\u003egetClass(),\r\n            'line' =\u003e $this-\u003egetLine(),\r\n            'code' =\u003e $this-\u003egetCode()\r\n        ]);\r\n        \r\n        // Log security violations\r\n        if ($this-\u003edetectSecurityIssue()) {\r\n            $this-\u003elogSecurityViolation('Suspicious exception pattern detected');\r\n        }\r\n    }\r\n    \r\n    private function detectSecurityIssue(): bool {\r\n        // Your security detection logic\r\n        return false;\r\n    }\r\n}\r\n```\r\n\r\n### CLI vs HTTP Output Examples\r\n\r\n#### CLI Output (Automatic Detection)\r\n```\r\n============================================================\r\nAPPLICATION ERROR\r\n============================================================\r\nLocation: MyClass line 42\r\nMessage: Database connection failed\r\n\r\nStack Trace:\r\n----------------------------------------\r\n#0 At class MyClass line 42\r\n#1 At class Application line 15\r\n----------------------------------------\r\n\r\nThis detailed error information is shown because you are in development mode.\r\nTime: 2024-01-15 10:30:45\r\n============================================================\r\n```\r\n\r\n#### HTTP Output (Automatic Detection)\r\n```html\r\n\u003cdiv class=\"error-container\"\u003e\r\n    \u003ch3 class=\"error-title\"\u003eApplication Error\u003c/h3\u003e\r\n    \u003cp\u003e\u003cstrong\u003eLocation:\u003c/strong\u003e MyClass line 42\u003c/p\u003e\r\n    \u003cp\u003e\u003cstrong\u003eMessage:\u003c/strong\u003e Database connection failed\u003c/p\u003e\r\n    \r\n    \u003cdetails class=\"error-trace\"\u003e\r\n        \u003csummary\u003e\u003cstrong\u003eStack Trace\u003c/strong\u003e\u003c/summary\u003e\r\n        \u003cpre class=\"error-trace-content\"\u003e\r\n#0 At class MyClass line 42\r\n#1 At class Application line 15\r\n        \u003c/pre\u003e\r\n    \u003c/details\u003e\r\n    \r\n    \u003cp class=\"error-help\"\u003eThis detailed error information is shown because you are in development mode.\u003c/p\u003e\r\n    \u003cp class=\"error-timestamp\"\u003eTime: 2024-01-15 10:30:45\u003c/p\u003e\r\n\u003c/div\u003e\r\n```\r\n\r\n## Advanced Examples\r\n\r\n### Production-Ready Handler\r\n\r\n```php\r\n\u003c?php\r\nuse WebFiori\\Error\\AbstractHandler;\r\nuse WebFiori\\Error\\Security\\SecurityConfig;\r\n\r\nclass ProductionHandler extends AbstractHandler {\r\n    public function __construct() {\r\n        parent::__construct();\r\n        $this-\u003esetName('Production Error Handler');\r\n        $this-\u003esetPriority(100);\r\n    }\r\n\r\n    public function createSecurityConfig(): SecurityConfig {\r\n        return new SecurityConfig('production');\r\n    }\r\n\r\n    public function handle(): void {\r\n        // Log the error securely\r\n        $this-\u003esecureLog('Production error occurred', [\r\n            'timestamp' =\u003e date('Y-m-d H:i:s'),\r\n            'user_agent' =\u003e $_SERVER['HTTP_USER_AGENT'] ?? 'CLI',\r\n            'request_uri' =\u003e $_SERVER['REQUEST_URI'] ?? 'CLI'\r\n        ]);\r\n\r\n        // Show minimal user-friendly message\r\n        if (php_sapi_name() === 'cli') {\r\n            echo \"\\033[1;31mAn error occurred. Please check the logs.\\033[0m\\n\";\r\n        } else {\r\n            echo '\u003cdiv style=\"color: red; padding: 20px; border: 1px solid red;\"\u003e';\r\n            echo '\u003ch3\u003eService Temporarily Unavailable\u003c/h3\u003e';\r\n            echo '\u003cp\u003eWe are experiencing technical difficulties. Please try again later.\u003c/p\u003e';\r\n            echo '\u003c/div\u003e';\r\n        }\r\n    }\r\n\r\n    public function isActive(): bool {\r\n        return $_ENV['APP_ENV'] === 'production';\r\n    }\r\n\r\n    public function isShutdownHandler(): bool {\r\n        return true; // Handle fatal errors\r\n    }\r\n}\r\n```\r\n\r\n### Development Handler with Enhanced Features\r\n\r\n```php\r\n\u003c?php\r\nuse WebFiori\\Error\\AbstractHandler;\r\nuse WebFiori\\Error\\Security\\SecurityConfig;\r\n\r\nclass DevelopmentHandler extends AbstractHandler {\r\n    public function __construct() {\r\n        parent::__construct();\r\n        $this-\u003esetName('Development Error Handler');\r\n        $this-\u003esetPriority(90);\r\n    }\r\n\r\n    public function createSecurityConfig(): SecurityConfig {\r\n        return new SecurityConfig('development');\r\n    }\r\n\r\n    public function handle(): void {\r\n        if (php_sapi_name() === 'cli') {\r\n            $this-\u003erenderCLIOutput();\r\n        } else {\r\n            $this-\u003erenderHTMLOutput();\r\n        }\r\n    }\r\n\r\n    private function renderCLIOutput(): void {\r\n        echo \"\\n\" . str_repeat('=', 60) . \"\\n\";\r\n        echo \"\\033[1;31mDEVELOPMENT ERROR\\033[0m\\n\";\r\n        echo str_repeat('=', 60) . \"\\n\";\r\n        echo \"\\033[1mClass:\\033[0m \" . $this-\u003egetClass() . \"\\n\";\r\n        echo \"\\033[1mLine:\\033[0m \" . $this-\u003egetLine() . \"\\n\";\r\n        echo \"\\033[1mMessage:\\033[0m \" . $this-\u003egetMessage() . \"\\n\";\r\n        \r\n        if ($this-\u003egetCode() !== '0') {\r\n            echo \"\\033[1mCode:\\033[0m \" . $this-\u003egetCode() . \"\\n\";\r\n        }\r\n        \r\n        echo \"\\n\\033[1mStack Trace:\\033[0m\\n\";\r\n        echo str_repeat('-', 40) . \"\\n\";\r\n        \r\n        foreach ($this-\u003egetTrace() as $index =\u003e $entry) {\r\n            echo \"#{$index} \" . (string)$entry . \"\\n\";\r\n        }\r\n        \r\n        echo str_repeat('=', 60) . \"\\n\\n\";\r\n    }\r\n\r\n    private function renderHTMLOutput(): void {\r\n        echo '\u003cdiv style=\"font-family: monospace; background: #f8f8f8; padding: 20px; border-left: 5px solid #ff0000;\"\u003e';\r\n        echo '\u003ch2 style=\"color: #ff0000; margin-top: 0;\"\u003eDevelopment Error\u003c/h2\u003e';\r\n        echo '\u003cp\u003e\u003cstrong\u003eClass:\u003c/strong\u003e ' . htmlspecialchars($this-\u003egetClass()) . '\u003c/p\u003e';\r\n        echo '\u003cp\u003e\u003cstrong\u003eLine:\u003c/strong\u003e ' . $this-\u003egetLine() . '\u003c/p\u003e';\r\n        echo '\u003cp\u003e\u003cstrong\u003eMessage:\u003c/strong\u003e ' . htmlspecialchars($this-\u003egetMessage()) . '\u003c/p\u003e';\r\n        \r\n        if ($this-\u003egetCode() !== '0') {\r\n            echo '\u003cp\u003e\u003cstrong\u003eCode:\u003c/strong\u003e ' . $this-\u003egetCode() . '\u003c/p\u003e';\r\n        }\r\n        \r\n        echo '\u003cdetails style=\"margin-top: 15px;\"\u003e';\r\n        echo '\u003csummary\u003e\u003cstrong\u003eStack Trace\u003c/strong\u003e\u003c/summary\u003e';\r\n        echo '\u003cpre style=\"background: #fff; padding: 10px; overflow-x: auto;\"\u003e';\r\n        \r\n        foreach ($this-\u003egetTrace() as $index =\u003e $entry) {\r\n            echo \"#{$index} \" . htmlspecialchars((string)$entry) . \"\\n\";\r\n        }\r\n        \r\n        echo '\u003c/pre\u003e\u003c/details\u003e\u003c/div\u003e';\r\n    }\r\n\r\n    public function isActive(): bool {\r\n        return $_ENV['APP_ENV'] === 'development' || $_ENV['APP_DEBUG'] === 'true';\r\n    }\r\n\r\n    public function isShutdownHandler(): bool {\r\n        return false;\r\n    }\r\n}\r\n```\r\n\r\n## Testing\r\n\r\nThe library includes a comprehensive test suite with 92 tests covering all functionality:\r\n\r\n```bash\r\n# Run all tests\r\ncomposer test\r\n\r\n# View test results with detailed output\r\nvendor/bin/phpunit -c tests/phpunit.xml --testdox\r\n```\r\n\r\n## Configuration Reference\r\n\r\n### HandlerConfig Options\r\n\r\n```php\r\nuse WebFiori\\Error\\Config\\HandlerConfig;\r\n\r\n$config = new HandlerConfig();\r\n\r\n// Error reporting settings\r\n$config-\u003esetErrorReporting(E_ALL);\r\n$config-\u003esetDisplayErrors(false);\r\n$config-\u003esetDisplayStartupErrors(false);\r\n\r\n// Global settings modification\r\n$config-\u003esetModifyGlobalSettings(true);\r\n$config-\u003esetRespectExistingSettings(false);\r\n\r\n// Apply the configuration\r\n$config-\u003eapply();\r\n```\r\n\r\n### SecurityConfig Options\r\n\r\n```php\r\nuse WebFiori\\Error\\Security\\SecurityConfig;\r\n\r\n$security = new SecurityConfig('production');\r\n\r\n// Control what information is shown\r\n$security-\u003eshouldShowStackTrace(); // Returns bool\r\n$security-\u003eshouldShowLineNumbers(); // Returns bool\r\n$security-\u003eshouldShowFullPaths(); // Returns bool\r\n\r\n// Check security level\r\n$security-\u003eisProduction(); // Returns bool\r\n$security-\u003eisDevelopment(); // Returns bool\r\n$security-\u003eisStaging(); // Returns bool\r\n```\r\n\r\n## Best Practices\r\n\r\n### Environment-Specific Handlers\r\n\r\n```php\r\n// Register different handlers for different environments\r\nif ($_ENV['APP_ENV'] === 'production') {\r\n    Handler::registerHandler(new ProductionHandler());\r\n} else {\r\n    Handler::registerHandler(new DevelopmentHandler());\r\n}\r\n\r\n// Always have a fallback\r\nHandler::registerHandler(new DefaultHandler(), 1);\r\n```\r\n\r\n### Logging Strategy\r\n\r\n```php\r\nclass LoggingHandler extends AbstractHandler {\r\n    public function handle(): void {\r\n        // Always log errors\r\n        $this-\u003esecureLog('Error occurred', [\r\n            'environment' =\u003e $_ENV['APP_ENV'],\r\n            'timestamp' =\u003e time(),\r\n            'memory_usage' =\u003e memory_get_usage(true)\r\n        ]);\r\n        \r\n        // Don't output in production\r\n        if ($_ENV['APP_ENV'] !== 'production') {\r\n            $this-\u003edisplayError();\r\n        }\r\n    }\r\n    \r\n    private function displayError(): void {\r\n        // Display error using secureOutput\r\n        $this-\u003esecureOutput(\"Error: \" . $this-\u003egetMessage());\r\n    }\r\n}\r\n```\r\n\r\n### Security Considerations\r\n\r\n```php\r\n// Never expose sensitive information\r\nclass SecureHandler extends AbstractHandler {\r\n    public function handle(): void {\r\n        // Use built-in sanitization\r\n        $sanitizedMessage = $this-\u003egetMessage(); // Already sanitized\r\n        \r\n        // Log security violations\r\n        if ($this-\u003eisSensitiveError()) {\r\n            $this-\u003elogSecurityViolation('Sensitive error detected');\r\n        }\r\n        \r\n        // Show generic message in production\r\n        if ($this-\u003ecreateSecurityConfig()-\u003eisProduction()) {\r\n            echo 'An error occurred. Please contact support.';\r\n        }\r\n    }\r\n    \r\n    private function isSensitiveError(): bool {\r\n        // Your security detection logic\r\n        return false;\r\n    }\r\n}\r\n```\r\n\r\n## Troubleshooting\r\n\r\n### Common Issues\r\n\r\n1. **Handler not triggering**: Ensure handlers are registered with `Handler::registerHandler()`\r\n2. **Memory issues**: Enable memory management in configuration\r\n3. **Infinite loops**: Enable infinite loop protection with `Handler::setMaxHandlerExecutions()`\r\n4. **Missing output**: Check if handler is active and has correct priority\r\n\r\n### Debug Mode\r\n\r\n```php\r\nuse WebFiori\\Error\\Config\\HandlerConfig;\r\nuse WebFiori\\Error\\Handler;\r\n\r\n// Enable debug mode for troubleshooting\r\n$config = HandlerConfig::createDevelopmentConfig();\r\nHandler::setConfig($config);\r\n```\r\n\r\n## License\r\n\r\nThis library is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Please read our contributing guidelines and submit pull requests to our GitHub repository.\r\n\r\n## Support\r\n\r\n- **Issues**: [GitHub Issues](https://github.com/WebFiori/err/issues)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebfiori%2Ferr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebfiori%2Ferr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebfiori%2Ferr/lists"}