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