wikimedia / normalized-exception
一个帮助异常与 PSR-3 日志良好合作的辅助工具
v1.0.1
2021-07-01 07:36 UTC
Requires
- php: >=7.2.9
Requires (Dev)
- mediawiki/mediawiki-codesniffer: 35.0.0
- mediawiki/mediawiki-phan-config: 0.10.6
- mediawiki/minus-x: 1.1.1
- ockcyp/covers-validator: 1.3.3
- php-parallel-lint/php-console-highlighter: ^0.5
- php-parallel-lint/php-parallel-lint: 1.2.0
- phpunit/phpunit: ^8.5|^9.5
This package is auto-updated.
Last update: 2024-09-12 06:01:11 UTC
README
NormalizedException
一个用于简化PSR-3异常处理的迷你库。
关于此库的更多文档可以在MediaWiki.org上找到。
使用方法
使用标准实现
use Wikimedia\NormalizedException\NormalizedException; throw new NormalizedException( 'Invalid value: {value}', [ 'value' => $value ] );
集成到另一个框架或库中
use Wikimedia\NormalizedException\INormalizedException; use Wikimedia\NormalizedException\NormalizedExceptionTrait; class MyException extends SomeException implements INormalizedException { use NormalizedExceptionTrait; public function __construct( string $normalizedMessage, array $messageContext = [] ) { $this->normalizedMessage = $normalizedMessage; $this->messageContext = $messageContext; parent::__construct( self::getMessageFromNormalizedMessage( $normalizedMessage, $messageContext ) ); } }
throw new MyException( 'Invalid value: {value}', [ 'value' => $value ] );
运行测试
composer install --dev
composer test