Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| CriticalSectionMismatchException | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | declare( strict_types = 1 ); |
| 3 | |
| 4 | namespace Wikimedia\RequestTimeout; |
| 5 | |
| 6 | use LogicException; |
| 7 | use Wikimedia\NormalizedException\INormalizedException; |
| 8 | use Wikimedia\NormalizedException\NormalizedExceptionTrait; |
| 9 | |
| 10 | /** |
| 11 | * An exception thrown when CriticalSectionProvider::exit() is called with a |
| 12 | * name not matching the one used in the prior CriticalSectionProvider::enter() |
| 13 | * call. |
| 14 | */ |
| 15 | class CriticalSectionMismatchException extends LogicException implements INormalizedException { |
| 16 | use NormalizedExceptionTrait; |
| 17 | |
| 18 | /** |
| 19 | * @param string $actual The name used in exit() |
| 20 | * @param string $expected The name used in enter(), or "[none]" if there |
| 21 | * was no enter() call. |
| 22 | */ |
| 23 | public function __construct( $actual, $expected ) { |
| 24 | $this->normalizedMessage = "Critical section name mismatch: expected {expected}, got $actual"; |
| 25 | $this->messageContext = [ 'expected' => $expected ]; |
| 26 | |
| 27 | parent::__construct( |
| 28 | $this->getMessageFromNormalizedMessage( $this->normalizedMessage, $this->messageContext ) |
| 29 | ); |
| 30 | } |
| 31 | } |