Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
CriticalSectionMismatchException
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2declare( strict_types = 1 );
3
4namespace Wikimedia\RequestTimeout;
5
6use LogicException;
7use Wikimedia\NormalizedException\INormalizedException;
8use 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 */
15class 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}