wikimedia / normalized-exception
A helper for making exceptions play nice with PSR-3 logging
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-10-12 06:10:17 UTC
README
NormalizedException
A minimal library to facilitate PSR-3-friendly exception handling.
Additional documentation about the library can be found on MediaWiki.org.
Usage
Use the standard implementation:
use Wikimedia\NormalizedException\NormalizedException; throw new NormalizedException( 'Invalid value: {value}', [ 'value' => $value ] );
Integrate into another framework or library:
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 ] );
Running tests
composer install --dev
composer test
History
This library was split out of MediaWiki changeset 670465 during the MediaWiki 1.37 development cycle.