{"id":37005322,"url":"https://github.com/mpyw/exceper","last_synced_at":"2026-01-14T00:40:03.921Z","repository":{"id":21185485,"uuid":"91868110","full_name":"mpyw/exceper","owner":"mpyw","description":"Provides temporary error handler automatically using set_error_handler() and restore_error_handler().","archived":true,"fork":false,"pushed_at":"2024-05-05T02:16:43.000Z","size":56,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-21T11:59:53.541Z","etag":null,"topics":["error","exception","handler","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/mpyw.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":"2017-05-20T05:44:06.000Z","updated_at":"2024-05-05T02:22:44.000Z","dependencies_parsed_at":"2024-05-05T03:21:52.099Z","dependency_job_id":"9a1794cf-de3a-440f-b083-57b11769c618","html_url":"https://github.com/mpyw/exceper","commit_stats":{"total_commits":33,"total_committers":3,"mean_commits":11.0,"dds":0.1515151515151515,"last_synced_commit":"6c6f31e3982532176793e12abd042dadc84e24e0"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/mpyw/exceper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpyw%2Fexceper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpyw%2Fexceper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpyw%2Fexceper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpyw%2Fexceper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mpyw","download_url":"https://codeload.github.com/mpyw/exceper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mpyw%2Fexceper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28406520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["error","exception","handler","php"],"created_at":"2026-01-14T00:40:03.659Z","updated_at":"2026-01-14T00:40:03.821Z","avatar_url":"https://github.com/mpyw.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Exceper [![Build Status](https://github.com/mpyw/exceper/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/mpyw/exceper/actions) [![Coverage Status](https://coveralls.io/repos/github/mpyw/exceper/badge.svg?branch=master)](https://coveralls.io/github/mpyw/exceper?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/mpyw/exceper/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/mpyw/exceper/?branch=master)\n\nProvides temporary error handler automatically using [`set_error_handler()`] and [`restore_error_handler()`].\n\n| PHP | :question: | Feature Restriction |\n|:---:|:---:|:---:|\n| 5.3.2~ | :smile: | Supported |\n| ~5.3.1 | :boom: | Incompatible |\n\n## Installing\n\n```\ncomposer require mpyw/exceper\n```\n\n## Quick Example\n\n```php\n\u003c?php\n\nrequire __DIR__ . '/vendor/autoload.php';\n\nuse Mpyw\\Exceper\\Convert;\n\ntry {\n\n    // We pick errors triggered by fopen() or fgets().\n    // They are converted into \\RuntimeException.\n    Convert::toRuntimeException(function () {\n        $fp = fopen('http://example.com', 'rb');\n        while (false !== $line = fgets($fp)) {\n            echo $line;\n        }\n    });\n\n} catch (\\RuntimeException $e) {\n\n    // Do something here\n\n}\n\n// Error handler is already automatically restored.\n```\n\n## API\n\n### Mpyw\\Exceper\\Convert::to()\u003cbr\u003eMpyw\\Exceper\\Convert::to`{$class}`()\n\nCapture errors to convert into an instance of the specified class.  \n\n- Error handlers are automatically restored.\n- **`-\u003egetFile()` and `-\u003egetLine()` returns correct locations** like `ErrorException` does.\n\n```php\nstatic Mpyw\\Exceper\\Convert::to(string $class, callable $callback, int $types = E_ALL | E_STRICT): mixed\nstatic Mpyw\\Exceper\\Convert::to{$class}(callable $callback, int $types = E_ALL | E_STRICT): mixed\nstatic Mpyw\\Exceper\\Convert::to(string $class, int $code, callable $callback, int $types = E_ALL | E_STRICT): mixed\nstatic Mpyw\\Exceper\\Convert::to{$class}(int $code, callable $callback, int $types = E_ALL | E_STRICT): mixed\n```\n\n#### Arguments\n\n- **`(string)`** __*$class*__\u003cbr /\u003e Conversion target class name which is an instance of `\\Exception` or `\\Throwable`. Please note that case-sensitivity of class name depends on the implementation of your autoloaders, which can cause an unexpected behavior if the target class is not loaded.\n- **`(int)`** __*$code*__\u003cbr /\u003e Error code passed to the constructor as the second argument. Default to `0`.\n- **`(callable)`** __*$callback*__\u003cbr /\u003e Callback function to be executed. This parameter SHOULD be used as `\\Closure` because arguments cannot be specified.\n- **`(int)`** __*$types*__\u003cbr /\u003e Bit mask of target error severities.\n\n#### Return Value\n\n**`(mixed)`**\u003cbr /\u003ePropagates upcoming value from `$callback()`.\n\n#### Exception\n\nConverted errors.\n\n### Mpyw\\Exceper\\Convert::silent()\n\nCapture errors but never throw anything.\n\n```php\nstatic Mpyw\\Exceper\\Convert::silent(callable $callback, int $types = E_ALL | E_STRICT, bool $captureExceptions = true): mixed\n```\n\n#### Arguments\n\n- **`(callable)`** __*$callback*__\u003cbr /\u003e Callback function to be executed. This parameter SHOULD be a `\\Closure` because arguments cannot be specified.\n- **`(int)`** __*$types*__\u003cbr /\u003e Bit mask of target error severities.\n- **`(bool)`** __*$captureExceptions*__\u003cbr /\u003e Capture exceptions that were directly thrown; not originated in `set_error_handler()`.\n\n#### Return Value\n\n**`(mixed)`**\u003cbr /\u003ePropagates upcoming value from `$callback()`. Returns `null` if something thrown.\n\n[`set_error_handler()`]: http://www.php.net/manual/function.set-error-handler.php\n[`restore_error_handler()`]: http://www.php.net/manual/function.restore-error-handler.php\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpyw%2Fexceper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmpyw%2Fexceper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmpyw%2Fexceper/lists"}