mouf/utils.composite-exception
最新稳定版本:v1.0.0
Composer 安装命令:
composer require mouf/utils.composite-exception
包简介
This project contains a simple PHP exception that can aggregate multiple exceptions in one.
README 文档
README
Composite exception
This project contains a simple PHP exception that can aggregate multiple exceptions in one. The rationale behind this idea is to allow exceptions to be triggered in loops, and to throw only one at the end of your script:
Installation
You can install this package through Composer:
{
"require": {
"mouf/utils.composite-exception": "~1.0"
}
}
The packages adheres to the SemVer specification, and there will be full backward compatibility between minor versions.
Usage
This package contains a CompositeException class with 2 methods: add(\Throwable $e) and isEmtpy().
Typical usage:
use Mouf\Utils\CompositeException; $compositeException = new CompositeException(); foreach (...) { try { // Do stuff } catch (\Exception $e) { // Add exceptions to the composite exception $compositeException->add($e); } } if (!$compositeException->isEmpty()) { // If not empty, let's throw the composite exception. throw $compositeException; }
统计信息
- 总下载量: 251.59k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-09-08