{"id":21571058,"url":"https://github.com/treblle/error-codes","last_synced_at":"2025-07-22T20:34:54.882Z","repository":{"id":190584980,"uuid":"682983781","full_name":"Treblle/error-codes","owner":"Treblle","description":"Treblle Error Codes is a PHP package that makes it easy to provide consistent error codes in your applications. With this package, you can easily determine the appropriate error code for any situation, and then access the associated attributes for that code","archived":false,"fork":false,"pushed_at":"2024-03-13T14:16:02.000Z","size":59,"stargazers_count":4,"open_issues_count":2,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-07-16T08:00:54.628Z","etag":null,"topics":["backend","error-monitoring","monitoring","package","php"],"latest_commit_sha":null,"homepage":"https://www.treblle.com/","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/Treblle.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":"2023-08-25T10:17:12.000Z","updated_at":"2023-09-21T09:22:50.000Z","dependencies_parsed_at":"2025-04-10T14:22:54.130Z","dependency_job_id":"ecb01cab-d3eb-45fa-b00a-b67aa684d322","html_url":"https://github.com/Treblle/error-codes","commit_stats":null,"previous_names":["treblle/error-codes"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Treblle/error-codes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Treblle%2Ferror-codes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Treblle%2Ferror-codes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Treblle%2Ferror-codes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Treblle%2Ferror-codes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Treblle","download_url":"https://codeload.github.com/Treblle/error-codes/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Treblle%2Ferror-codes/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266567748,"owners_count":23949407,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["backend","error-monitoring","monitoring","package","php"],"created_at":"2024-11-24T11:14:46.164Z","updated_at":"2025-07-22T20:34:54.860Z","avatar_url":"https://github.com/Treblle.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://treblle-github.s3.us-east-1.amazonaws.com/github-header.jpg\"/\u003e\n\u003c/div\u003e\n\u003cdiv align=\"center\"\u003e\n\n# API Error Codes\n\n\u003c!-- BADGES_START --\u003e\n[![Latest Version][badge-release]][packagist]\n[![PHP Version][badge-php]][php]\n![tests](https://github.com/treblle/error-codes/workflows/tests/badge.svg)\n[![Total Downloads][badge-downloads]][downloads]\n\n[badge-release]: https://img.shields.io/packagist/v/treblle/error-codes.svg?style=flat-square\u0026label=release\n[badge-php]: https://img.shields.io/packagist/php-v/treblle/error-codes.svg?style=flat-square\n[badge-downloads]: https://img.shields.io/packagist/dt/treblle/error-codes.svg?style=flat-square\u0026colorB=mediumvioletred\n\n[packagist]: https://packagist.org/packages/treblle/error-codes\n[php]: https://php.net\n[downloads]: https://packagist.org/packages/treblle/error-codes\n\u003c!-- BADGES_END --\u003e\n\n\u003ca href=\"https://docs.treblle.com/en/integrations\" target=\"_blank\"\u003eIntegrations\u003c/a\u003e\n\u003cspan\u003e\u0026nbsp;\u0026nbsp;•\u0026nbsp;\u0026nbsp;\u003c/span\u003e\n\u003ca href=\"http://treblle.com/\" target=\"_blank\"\u003eWebsite\u003c/a\u003e\n\u003cspan\u003e\u0026nbsp;\u0026nbsp;•\u0026nbsp;\u0026nbsp;\u003c/span\u003e\n\u003ca href=\"https://docs.treblle.com\" target=\"_blank\"\u003eDocs\u003c/a\u003e\n\u003cspan\u003e\u0026nbsp;\u0026nbsp;•\u0026nbsp;\u0026nbsp;\u003c/span\u003e\n\u003ca href=\"https://blog.treblle.com\" target=\"_blank\"\u003eBlog\u003c/a\u003e\n\u003cspan\u003e\u0026nbsp;\u0026nbsp;•\u0026nbsp;\u0026nbsp;\u003c/span\u003e\n\u003ca href=\"https://twitter.com/treblleapi\" target=\"_blank\"\u003eTwitter\u003c/a\u003e\n\u003cspan\u003e\u0026nbsp;\u0026nbsp;•\u0026nbsp;\u0026nbsp;\u003c/span\u003e\n\u003ca href=\"https://treblle.com/chat\" target=\"_blank\"\u003eDiscord\u003c/a\u003e\n\u003cbr /\u003e\n\n  \u003chr /\u003e\n\u003c/div\u003e\n\nA package to help you provide consistent error codes.\n\n## Installation\n\n```bash\ncomposer require treblle/error-codes\n```\n\n## Usage\n\nThis package is easy to use, you can determine what Error Code you need. Then access the attributes attached to it.\n\n```php\nuse Treblle\\ErrorCodes\\Enums\\ErrorCode;\n\n$badRequest = ErrorCode::BAD_REQUEST;\n\n$title = $badRequest-\u003egetDescription()-\u003etitle; // Bad Request\n$code = $badRequest-\u003egetDescription()-\u003ecode; // HTTP_400\n$link = $badRequest-\u003egetDescription()-\u003elink; // https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400\n$status = $badRequest-\u003egetDescription()-\u003estatus; // 400\n```\n\n## Combining\n\nThis package works very well with the `treblle/api-responses` package.\n\n```php\nfinal class Handler extends ExceptionHandler\n{\n    public function register(): void\n    {\n        $this-\u003erenderable(function (ModelNotFoundException $exception, Request $request) {\n            $errorCode = \\Treblle\\ErrorCodes\\Enums\\ErrorCode::NOT_FOUND;\n            \n            return new ErrorResponse(\n                data: new ApiError(\n                    title: $errorCode-\u003egetDescription()-\u003etitle,\n                    detail: $exception-\u003egetMessage(),\n                    instance: $request-\u003epath(),\n                    code: $errorCode-\u003egetDescription()-\u003ecode,\n                    link: $errorCode-\u003egetDescription()-\u003elink,\n                ),\n                status: Status::NOT_FOUND,\n            );\n        });\n    }\n}\n```\n\n## Community 💙\n\nFirst and foremost: **Star and watch this repository** to stay up-to-date.\n\nAlso, follow our [Blog](https://blog.treblle.com), and on [Twitter](https://twitter.com/treblleapi).\n\nYou can chat with the team and other members on [Discord](https://treblle.com/chat) and follow our tutorials and other video material at [YouTube](https://youtube.com/@treblle).\n\n[![Treblle Discord](https://img.shields.io/badge/Treblle%20Discord-Join%20our%20Discord-F3F5FC?labelColor=7289DA\u0026style=for-the-badge\u0026logo=discord\u0026logoColor=F3F5FC\u0026link=https://treblle.com/chat)](https://treblle.com/chat)\n\n[![Treblle YouTube](https://img.shields.io/badge/Treblle%20YouTube-Subscribe%20on%20YouTube-F3F5FC?labelColor=c4302b\u0026style=for-the-badge\u0026logo=YouTube\u0026logoColor=F3F5FC\u0026link=https://youtube.com/@treblle)](https://youtube.com/@treblle)\n\n[![Treblle on Twitter](https://img.shields.io/badge/Treblle%20on%20Twitter-Follow%20Us-F3F5FC?labelColor=1DA1F2\u0026style=for-the-badge\u0026logo=Twitter\u0026logoColor=F3F5FC\u0026link=https://twitter.com/treblleapi)](https://twitter.com/treblleapi)\n\n### How to contribute\n\nHere are some ways of contributing to making Treblle better:\n\n- **[Try out Treblle](https://docs.treblle.com/en/introduction#getting-started)**, and let us know ways to make Treblle better for you. Let us know here on [Discord](https://treblle.com/chat).\n- Join our [Discord](https://treblle.com/chat) and connect with other members to share and learn from.\n- Send a pull request to any of our [open source repositories](https://github.com/Treblle) on Github. Check the contribution guide on the repo you want to contribute to for more details about how to contribute. We're looking forward to your contribution!\n-\n## Testing\n\nTo run the test suite:\n\n```bash\ncomposer run test\n```\n\n## Credits\n\n\u003ca href=\"https://github.com/Treblle/error-codes/graphs/contributors\"\u003e\n  \u003cp align=\"center\"\u003e\n    \u003cimg  src=\"https://contrib.rocks/image?repo=Treblle/error-codes\" alt=\"A table of avatars from the project's contributors\" /\u003e\n  \u003c/p\u003e\n\u003c/a\u003e\n\n## LICENSE\n\nThe MIT LIcense (MIT). Please see [License File](./LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreblle%2Ferror-codes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftreblle%2Ferror-codes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreblle%2Ferror-codes/lists"}