NormalizedException
Appearance
NormalizedException is a minimal PHP library to facilitate PSR-3-friendly exception handling.
Usage
[edit]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 ] );