| 1 |
<?php |
| 2 |
|
| 3 |
namespace Wikimedia\NormalizedException; |
| 4 |
|
| 5 |
use Exception; |
| 6 |
use Throwable; |
| 7 |
|
| 8 |
/** |
| 9 |
* Basic normalized exception. |
| 10 |
* |
| 11 |
* @newable |
| 12 |
* @stable to extend |
| 13 |
*/ |
| 14 |
class NormalizedException extends Exception implements INormalizedException { |
| 15 |
|
| 16 |
use NormalizedExceptionTrait; |
| 17 |
|
| 18 |
/** |
| 19 |
* @stable to call |
| 20 |
* @param string $normalizedMessage The exception message, with PSR-3 style placeholders. |
| 21 |
* @param array $messageContext Message context, with values for the placeholders. |
| 22 |
* @param int $code The exception code. |
| 23 |
* @param Throwable|null $previous The previous throwable used for the exception chaining. |
| 24 |
*/ |
| 25 |
public function __construct( |
| 26 |
string $normalizedMessage, |
| 27 |
array $messageContext = [], |
| 28 |
int $code = 0, |
| 29 |
?Throwable $previous = null |
| 30 |
) { |
| 31 |
$this->normalizedMessage = $normalizedMessage; |
| 32 |
$this->messageContext = $messageContext; |
| 33 |
parent::__construct( |
| 34 |
self::getMessageFromNormalizedMessage( $normalizedMessage, $messageContext ), |
| 35 |
$code, |
| 36 |
$previous |
| 37 |
); |
| 38 |
} |
| 39 |
|
| 40 |
} |