Completed
Push — master ( 01a3d7...cd5a13 )
by Adam
03:05
created

OnErrorHandler::__invoke()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 0
cts 6
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 2
crap 12
1
<?php
2
/**
3
 * OnErrorHandler.php
4
 *
5
 * @copyright      More in license.md
6
 * @license        https://www.ipublikuj.eu
7
 * @author         Adam Kadlec https://www.ipublikuj.eu
8
 * @package        iPublikuj:NewRelic!
9
 * @subpackage     Events
10
 * @since          1.0.0
11
 *
12
 * @date           25.05.14
13
 */
14
15
declare(strict_types = 1);
16
17
namespace IPub\NewRelic\Events;
18
19
use Nette;
20
use Nette\Application;
21
22
/**
23
 * On application error event
24
 *
25
 * @package        iPublikuj:NewRelic!
26
 * @subpackage     Events
27
 *
28
 * @author         Adam Kadlec <[email protected]>
29
 */
30 1
final class OnErrorHandler
31
{
32
	/**
33
	 * Implement nette smart magic
34
	 */
35 1
	use Nette\SmartObject;
36
37
	/**
38
	 * @param Application\Application $app
39
	 * @param \Exception|\TypeError $ex
40
	 *
41
	 * @return void
42
	 */
43
	public function __invoke(Application\Application $app, $ex) : void
44
	{
45
		// Check if new relict extension is loaded
46
		if (!extension_loaded('newrelic')) {
47
			return;
48
		}
49
50
		if ($ex instanceof Application\BadRequestException) {
51
			return; // Skip
52
		}
53
54
		// Log only errors with code 500
55
		newrelic_notice_error($ex->getMessage(), $ex);
56
	}
57
}
58