PHP code example of wikimedia / normalized-exception
1. Go to this page and download the library: Download wikimedia/normalized-exception library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wikimedia / normalized-exception example snippets
use Wikimedia\NormalizedException\NormalizedException;
throw new NormalizedException( 'Invalid value: {value}', [ 'value' => $value ] );
use Exception
use Wikimedia\NormalizedException\INormalizedException;
use Wikimedia\NormalizedException\NormalizedExceptionTrait;
class MyException extends Exception implements INormalizedException {
use NormalizedExceptionTrait {
NormalizedExceptionTrait::normalizedConstructor as __construct;
}
}
use Wikimedia\NormalizedException\INormalizedException;
use Wikimedia\NormalizedException\NormalizedExceptionTrait;
class MyException extends SomeException implements INormalizedException {
use NormalizedExceptionTrait;
public function __construct(
string $normalizedMessage,
array $messageContext = [],
$otherParam1,
$otherParam2
) {
// these properties are defined by the trait and must be set
$this->normalizedMessage = $normalizedMessage;
$this->messageContext = $messageContext;
// replaces the PSR-3 tokens
$message = self::getMessageFromNormalizedMessage( $normalizedMessage, $messageContext );
parent::__construct( $message, $otherParam1, $otherParam2 );
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.