blob: 0b37d0128c958532304be3ef823b4757362cfc88 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
<?php
namespace MediaWiki\Rest\Reporter;
use MediaWiki\Rest\Handler;
use MediaWiki\Rest\RequestInterface;
use Throwable;
/**
* Error reporter based on php's native trigger_error() method.
* @since 1.38
*/
class PHPErrorReporter implements ErrorReporter {
/** @var int */
private $level;
/**
* @param int $level The error level to pass to trigger_error
*/
public function __construct( $level = E_USER_WARNING ) {
$this->level = $level;
}
/**
* @param Throwable $error
* @param Handler|null $handler
* @param RequestInterface $request
*/
public function reportError( Throwable $error, ?Handler $handler, RequestInterface $request ) {
$firstLine = preg_split( '#$#m', (string)$error, 0 )[0];
trigger_error( $firstLine, $this->level );
}
}
|