{"id":14966450,"url":"https://github.com/yiisoft/friendly-exception","last_synced_at":"2025-04-09T13:09:26.073Z","repository":{"id":54305965,"uuid":"209824221","full_name":"yiisoft/friendly-exception","owner":"yiisoft","description":"An interface for an exception to be friendly","archived":false,"fork":false,"pushed_at":"2024-05-18T14:24:33.000Z","size":64,"stargazers_count":48,"open_issues_count":1,"forks_count":8,"subscribers_count":20,"default_branch":"master","last_synced_at":"2024-10-29T14:35:39.970Z","etag":null,"topics":["error-handling","exception","exceptions","friendly","hacktoberfest","yii3"],"latest_commit_sha":null,"homepage":"https://www.yiiframework.com/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yiisoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"open_collective":"yiisoft","github":["yiisoft"]}},"created_at":"2019-09-20T15:32:45.000Z","updated_at":"2024-06-26T09:44:33.000Z","dependencies_parsed_at":"2023-01-24T06:30:12.660Z","dependency_job_id":"908f70c3-5144-4a71-931b-0bff68561a33","html_url":"https://github.com/yiisoft/friendly-exception","commit_stats":{"total_commits":60,"total_committers":11,"mean_commits":5.454545454545454,"dds":0.4833333333333333,"last_synced_commit":"6ac4245c47cf2445d94ed4b696b8dbdc60971589"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":"yiisoft/package-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Ffriendly-exception","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Ffriendly-exception/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Ffriendly-exception/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Ffriendly-exception/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yiisoft","download_url":"https://codeload.github.com/yiisoft/friendly-exception/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045245,"owners_count":21038554,"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","exception","exceptions","friendly","hacktoberfest","yii3"],"created_at":"2024-09-24T13:36:24.235Z","updated_at":"2025-04-09T13:09:26.052Z","avatar_url":"https://github.com/yiisoft.png","language":"PHP","funding_links":["https://opencollective.com/yiisoft","https://github.com/sponsors/yiisoft"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/yiisoft\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://yiisoft.github.io/docs/images/yii_logo.svg\" height=\"100px\" alt=\"Yii\"\u003e\n    \u003c/a\u003e\n    \u003ch1 align=\"center\"\u003eYii Friendly Exception\u003c/h1\u003e\n    \u003cbr\u003e\n\u003c/p\u003e\n\n[![Latest Stable Version](https://poser.pugx.org/yiisoft/friendly-exception/v)](https://packagist.org/packages/yiisoft/friendly-exception)\n[![Total Downloads](https://poser.pugx.org/yiisoft/friendly-exception/downloads)](https://packagist.org/packages/yiisoft/friendly-exception)\n\nAn exception interface that provides a friendly name and a possible solution.\nError handlers may consider the interface to render additional information right at the error screen.\n\n## Requirements\n\n- PHP 7.4 or higher.\n\n## Installation\n\nThe package could be installed with [Composer](https://getcomposer.org):\n\n```shell\ncomposer require yiisoft/friendly-exception\n```\n\n## General usage\n\n### Implementing friendly exception\n\nTo make exception friendly require this package and implement `FriendlyExceptionInterface`:\n\n```php\nuse Yiisoft\\FriendlyException\\FriendlyExceptionInterface;\n\nclass RequestTimeoutException extends \\RuntimeException implements FriendlyExceptionInterface\n{\n    public function getName(): string\n    {\n        return 'Request timed out.';\n    }\n    \n    public function getSolution(): ?string\n    {\n        return \u003c\u003c\u003c'SOLUTION'\n            Likely it is a result of resource request is not responding in a timely fashion. Try increasing timeout.\n            SOLUTION;\n    }\n}\n```\n\nWhen returning solution consider the following best practices:\n\n1. Make solution description as short as possible.\n2. Do not use HTML tags.\n3. Use [simple markdown](https://commonmark.org/help/).\n\n### Handling friendly exception\n\nTo make your exception handler render friendly exceptions:\n\n```php\nuse Yiisoft\\FriendlyException\\FriendlyExceptionInterface;\n\nclass ThrowableHandler\n{\n    public function handle(\\Throwable $t)\n    {\n        if ($t instanceof FriendlyExceptionInterface) {\n            // additional handling\n        }\n        // regular handling\n    }\n}\n```\n\nDo not forget to [render markdown](https://github.com/commonmark/commonmark-spec/wiki/List-of-CommonMark-Implementations#php).\n\n## Documentation\n\n- [Internals](docs/internals.md)\n\nIf you need help or have a question, the [Yii Forum](https://forum.yiiframework.com/c/yii-3-0/63) is a good place for that.\nYou may also check out other [Yii Community Resources](https://www.yiiframework.com/community).\n\n## License\n\nThe Yii Friendly Exception is free software. It is released under the terms of the BSD License.\nPlease see [`LICENSE`](./LICENSE.md) for more information.\n\nMaintained by [Yii Software](https://www.yiiframework.com/).\n\n## Support the project\n\n[![Open Collective](https://img.shields.io/badge/Open%20Collective-sponsor-7eadf1?logo=open%20collective\u0026logoColor=7eadf1\u0026labelColor=555555)](https://opencollective.com/yiisoft)\n\n## Follow updates\n\n[![Official website](https://img.shields.io/badge/Powered_by-Yii_Framework-green.svg?style=flat)](https://www.yiiframework.com/)\n[![Twitter](https://img.shields.io/badge/twitter-follow-1DA1F2?logo=twitter\u0026logoColor=1DA1F2\u0026labelColor=555555?style=flat)](https://twitter.com/yiiframework)\n[![Telegram](https://img.shields.io/badge/telegram-join-1DA1F2?style=flat\u0026logo=telegram)](https://t.me/yii3en)\n[![Facebook](https://img.shields.io/badge/facebook-join-1DA1F2?style=flat\u0026logo=facebook\u0026logoColor=ffffff)](https://www.facebook.com/groups/yiitalk)\n[![Slack](https://img.shields.io/badge/slack-join-1DA1F2?style=flat\u0026logo=slack)](https://yiiframework.com/go/slack)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiisoft%2Ffriendly-exception","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyiisoft%2Ffriendly-exception","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiisoft%2Ffriendly-exception/lists"}