markenwerk/common-exceptions
最新稳定版本:3.0.2
Composer 安装命令:
composer require markenwerk/common-exceptions
包简介
A PHP library providing common exception classes used by different projects.
关键字:
README 文档
README
A PHP library providing common exception classes used by different projects.
Installation
{
"require": {
"chroma-x/common-exceptions": "~3.0"
}
}
Usage
Autoloading and namesapce
require_once('path/to/vendor/autoload.php');
Handling exceptions
Catching by concrete class
try{
// Perform something maybe throwing an exception
} catch (ChromaX\CommonException\NetworkException\ConnectionException $exception) {
// API is not reachable
} catch (ChromaX\CommonException\NetworkException\CurlException $exception) {
// Curl failed
} catch (ChromaX\CommonException\ApiException\InvalidResponseException $exception) {
// API returns an unexpected result
} catch (ChromaX\CommonException\ApiException\RequestQuotaException $exception) {
// API requests over the allowed limit
} catch (ChromaX\CommonException\ApiException\NoResultsException $exception) {
// API request had no result
} catch (ChromaX\CommonException\IoException\FileWriteException $exception) {
// Log file was not writable
}
Catching by parent class
try{
// Perform something maybe throwing an exception
} catch (ChromaX\CommonException\NetworkException\Base\NetworkException $exception) {
// Any network exception was thrown
} catch (ChromaX\CommonException\ApiException\Base\ApiException $exception) {
// Any API exception was thrown
} catch (ChromaX\CommonException\IoException\Base\IoException $exception) {
// Any IO exception was thrown
}
Catching by grand parent class
try{
// Perform something maybe throwing an exception
} catch (ChromaX\CommonException\Base\BaseException $exception) {
// Any exception was thrown
}
Contribution
Contributing to our projects is always very appreciated.
But: please follow the contribution guidelines written down in the CONTRIBUTING.md document.
License
PHP Common Exceptions is under the MIT license.
统计信息
- 总下载量: 18.2k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-04-25