wikimedia / normalized-exception
A helper for making exceptions play nice with PSR-3 logging
v2.0.0
2024-11-10 01:02 UTC
Requires
- php: >=7.4
Requires (Dev)
- mediawiki/mediawiki-codesniffer: 45.0.0
- mediawiki/mediawiki-phan-config: 0.14.0
- mediawiki/minus-x: 1.1.3
- ockcyp/covers-validator: 1.6.0
- php-parallel-lint/php-console-highlighter: 1.0.0
- php-parallel-lint/php-parallel-lint: 1.4.0
- phpunit/phpunit: 9.6.16
This package is auto-updated.
Last update: 2024-11-30 04:04:29 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.