{"id":21467398,"url":"https://github.com/elusivecodes/fyreerror","last_synced_at":"2025-07-15T05:31:25.556Z","repository":{"id":56982776,"uuid":"477315979","full_name":"elusivecodes/FyreError","owner":"elusivecodes","description":"FyreError is a free, open-source error handling library for PHP.","archived":false,"fork":false,"pushed_at":"2024-11-15T10:48:57.000Z","size":132,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-15T11:32:28.854Z","etag":null,"topics":["error","exception","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elusivecodes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2022-04-03T11:07:33.000Z","updated_at":"2024-11-15T10:48:42.000Z","dependencies_parsed_at":"2024-06-29T07:56:41.148Z","dependency_job_id":null,"html_url":"https://github.com/elusivecodes/FyreError","commit_stats":{"total_commits":3,"total_committers":1,"mean_commits":3.0,"dds":0.0,"last_synced_commit":"1801a8565e1747ec29905cecd2a789130e0175d6"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreError","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreError/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreError/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyreError/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elusivecodes","download_url":"https://codeload.github.com/elusivecodes/FyreError/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226017463,"owners_count":17560515,"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","exception","php"],"created_at":"2024-11-23T08:17:52.023Z","updated_at":"2025-07-15T05:31:25.537Z","avatar_url":"https://github.com/elusivecodes.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FyreError\r\n\r\n**FyreError** is a free, open-source error handling library for *PHP*.\r\n\r\n\r\n## Table Of Contents\r\n- [Installation](#installation)\r\n- [Basic Usage](#basic-usage)\r\n- [Methods](#methods)\r\n- [Middleware](#middleware)\r\n- [Exceptions](#exceptions)\r\n    - [Http Exceptions](#http-exceptions)\r\n\r\n\r\n\r\n## Installation\r\n\r\n**Using Composer**\r\n\r\n```\r\ncomposer require fyre/error\r\n```\r\n\r\nIn PHP:\r\n\r\n```php\r\nuse Fyre\\Error\\ErrorHandler;\r\n```\r\n\r\n\r\n## Basic Usage\r\n\r\n- `$container` is a [*Container*](https://github.com/elusivecodes/FyreContainer).\r\n- `$io` is a [*Console*](https://github.com/elusivecodes/FyreConsole).\r\n- `$logManager` is a [*LogManager*](https://github.com/elusivecodes/FyreLog).\r\n- `$eventManager` is an [*EventManager*](https://github.com/elusivecodes/FyreEvent).\r\n- `$config` is a [*Config*](https://github.com/elusivecodes/FyreConfig).\r\n\r\n```php\r\n$errorHandler = new ErrorHandler($container, $io, $logManager, $eventManager, $config);\r\n```\r\n\r\nDefault configuration options will be resolved from the \"*Error*\" key in the [*Config*](https://github.com/elusivecodes/FyreConfig).\r\n\r\n- `$options` is an array containing the configuration options.\r\n    - `level` is a number representing the error reporting level, and will default to `E_ALL`.\r\n    - `renderer` is a *Closure* that will be used to render an *Exception*, and will default to *null*.\r\n    - `log` is a boolean indicating whether to log exception messages, and will default to *true*.\r\n\r\n```php\r\n$container-\u003euse(Config::class)-\u003eset('Error', $options);\r\n```\r\n\r\n**Autoloading**\r\n\r\nIt is recommended to bind the *ErrorHandler* to the [*Container*](https://github.com/elusivecodes/FyreContainer) as a singleton.\r\n\r\n```php\r\n$container-\u003esingleton(ErrorHandler::class);\r\n```\r\n\r\nAny dependencies will be injected automatically when loading from the [*Container*](https://github.com/elusivecodes/FyreContainer).\r\n\r\n```php\r\n$errorHandler = $container-\u003euse(ErrorHandler::class);\r\n```\r\n\r\n\r\n## Methods\r\n\r\n**Disable CLI**\r\n\r\nDisable CLI error handling.\r\n\r\n```php\r\n$errorHandler-\u003edisableCli();\r\n```\r\n\r\n**Enable CLI**\r\n\r\nEnable CLI error handling.\r\n\r\n```php\r\n$errorHandler-\u003eenableCli();\r\n```\r\n\r\n**Get Exception**\r\n\r\nGet the current *Exception*.\r\n\r\n```php\r\n$exception = $errorHandler-\u003egetException();\r\n```\r\n\r\n**Get Renderer**\r\n\r\nGet the error renderer.\r\n\r\n```php\r\n$renderer = $errorHandler-\u003egetRenderer();\r\n```\r\n\r\n**Register**\r\n\r\nRegister the error handler.\r\n\r\n```php\r\n$errorHandler-\u003eregister();\r\n```\r\n\r\n**Render**\r\n\r\nRender an *Exception*.\r\n\r\n```php\r\n$response = $errorHandler-\u003erender($exception);\r\n```\r\n\r\n**Set Renderer**\r\n\r\nSet the error renderer.\r\n\r\n- `$renderer` is a *Closure* that accepts an *Exception* as the first argument.\r\n\r\n```php\r\n$errorHandler-\u003esetRenderer($renderer);\r\n```\r\n\r\nThe renderer should return a [*ClientResponse*](https://github.com/elusivecodes/FyreServer#client-responses) or a string.\r\n\r\n**Unregister**\r\n\r\nUnregister the error handler.\r\n\r\n```php\r\n$errorHandler-\u003eunregister();\r\n```\r\n\r\n\r\n## Middleware\r\n\r\n```php\r\nuse Fyre\\Error\\Middleware\\ErrorHandlerMiddleware;\r\n```\r\n\r\n- `$errorHandler` is an *ErrorHandler*.\r\n\r\n```php\r\n$middleware = new ErrorHandlerMiddleware($errorHandler);\r\n```\r\n\r\nAny dependencies will be injected automatically when loading from the [*Container*](https://github.com/elusivecodes/FyreContainer).\r\n\r\n```php\r\n$middleware = $container-\u003euse(ErrorHandlerMiddleware::class);\r\n```\r\n\r\n**Handle**\r\n\r\n- `$request` is a [*ServerRequest*](https://github.com/elusivecodes/FyreServer#server-requests).\r\n- `$next` is a *Closure*.\r\n\r\n```php\r\n$response = $middleware-\u003ehandle($request, $next);\r\n```\r\n\r\nThis method will return a [*ClientResponse*](https://github.com/elusivecodes/FyreServer#client-responses).\r\n\r\n\r\n## Exceptions\r\n\r\nCustom exceptions can be created by extending the `Fyre\\Error\\Exceptions\\Exception` class.\r\n\r\n- `$message` is a string representing the error message.\r\n- `$code` is a number representing the error code, and will default to *500*.\r\n- `$previous` is an *Exception* representing the previous exception, and will default to *null*.\r\n\r\n```php\r\nnew Exception($message, $code, $previous);\r\n```\r\n\r\n\r\n### Http Exceptions\r\n\r\n**Bad Request**\r\n\r\n400 Bad Request error.\r\n\r\n```php\r\nuse Fyre\\Error\\Exceptions\\BadRequestException;\r\n```\r\n\r\n**Unauthorized**\r\n\r\n401 Unauthorized error.\r\n\r\n```php\r\nuse Fyre\\Error\\Exceptions\\UnauthorizedException;\r\n```\r\n\r\n**Forbidden**\r\n\r\n403 Forbidden error.\r\n\r\n```php\r\nuse Fyre\\Error\\Exceptions\\Forbidden;\r\n```\r\n\r\n**Not Found**\r\n\r\n404 Not Found error.\r\n\r\n```php\r\nuse Fyre\\Error\\Exceptions\\NotFoundException;\r\n```\r\n\r\n**Method Not Allowed**\r\n\r\n405 Method Not Allowed error.\r\n\r\n```php\r\nuse Fyre\\Error\\Exceptions\\MethodNotAllowedException;\r\n```\r\n\r\n**Not Acceptable**\r\n\r\n406 Not Acceptable error.\r\n\r\n```php\r\nuse Fyre\\Error\\Exceptions\\NotAcceptableException;\r\n```\r\n\r\n**Conflict**\r\n\r\n409 Conflict error.\r\n\r\n```php\r\nuse Fyre\\Error\\Exceptions\\ConflictException;\r\n```\r\n\r\n**Gone**\r\n\r\n410 Gone error.\r\n\r\n```php\r\nuse Fyre\\Error\\Exceptions\\GoneException;\r\n```\r\n\r\n**Internal Server**\r\n\r\n500 Internal Server error.\r\n\r\n```php\r\nuse Fyre\\Error\\Exceptions\\InternalServerException;\r\n```\r\n\r\n**Not Implemented**\r\n\r\n501 Not Implemented error.\r\n\r\n```php\r\nuse Fyre\\Error\\Exceptions\\NotImplementedException;\r\n```\r\n\r\n**Service Unavailable**\r\n\r\n503 Service Unavailable error.\r\n\r\n```php\r\nuse Fyre\\Error\\Exceptions\\ServiceUnavailableException;\r\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffyreerror","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felusivecodes%2Ffyreerror","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffyreerror/lists"}