holicz/simple-exception
Composer 安装命令:
composer require holicz/simple-exception
包简介
Simple base exception class
README 文档
README
Simple base exception class providing public and private context inspired by https://github.com/EasyCorp/EasyAdminBundle
Installation and usage
Installation with composer
composer require holicz/simple-exception
Your exception class:
<?php namespace App\Exception; use holicz\SimpleException\BaseException; use holicz\SimpleException\ExceptionContext; class CouldNotRemoveArticleException extends BaseException { public function __construct(int $id) { $exceptionContext = new ExceptionContext( 'There was an error during article removal. Please try again later.', sprintf('Could not delete article with id %d', $id), 500 // HTTP status code ); parent::__construct($exceptionContext); } }
Your code
try { ... } catch (MyException $e) { // Available methods $e->getPublicMessage(); // Show to user $e->getDebugMessage(); // Log $e->getStatusCode(); }
统计信息
- 总下载量: 3.54k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-03-19