Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
ExtensionError
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2declare( strict_types = 1 );
3
4namespace Wikimedia\Parsoid\Ext;
5
6use Exception;
7
8/**
9 * Exception thrown to halt extension tag content parsing and produce standard
10 * error output.
11 *
12 * $key and $params are basically the arguments to wfMessage, although they
13 * will be stored in the data-mw of the encapsulation wrapper.
14 *
15 * See https://www.mediawiki.org/wiki/Specs/HTML#Error_handling
16 */
17class ExtensionError extends Exception {
18
19    /**
20     * @var array
21     */
22    public $err;
23
24    /**
25     * @param string $key
26     * @param mixed ...$params
27     */
28    public function __construct(
29        string $key = 'mw-extparse-error', ...$params
30    ) {
31        parent::__construct();
32        $this->err = [ 'key' => $key ];
33        if ( count( $params ) > 0 ) {
34            $this->err['params'] = $params;
35        }
36    }
37
38}