spencer-mortensen/exceptions
最新稳定版本:6.0.3
Composer 安装命令:
composer require spencer-mortensen/exceptions
包简介
Catch fatal errors and warnings that would otherwise be difficult to handle
关键字:
README 文档
README
This project is available as a Composer Package:
spencer-mortensen/exceptions
Overview
Error handling in PHP is complicated, but this library makes it bullet-proof:
Create a method to handle exceptions (e.g. $handler->handle($throwable);) and you're good to go!
This library converts all PHP notices, warnings, and errors into exceptions, so you can handle them. It also works on any thrown exceptions that make it up to the global scope. It even catches most of the fatal errors, which would otherwise be impossible to handle.
Usage
Example 1. Enable error handling for the entire program:
new ErrorHandling($errorHandler, E_ALL);
Example 2. Enable error handling ONLY for your portion of the code:
try { ErrorHandling::on(); ... } finally { ErrorHandling::off(); }
This converts PHP notices, warnings, and errors into catchable exceptions, but only for the duration of the try/catch block.
Example 3. Show the built-in PHP STDERR messages, so you can see errors while you're working on your error handler. If you're working on your error handler, and you're getting a blank screen, use this:
new ErrorHandling($errorHandler, E_ALL, false);
When you're finished, set everything back to normal:
new ErrorHandling($errorHandler, E_ALL);
See the example area for working code and ideas.
统计信息
- 总下载量: 38.16k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0-or-later
- 更新时间: 2018-01-01