Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Functions
error_handler.php File Reference

Go to the source code of this file.

Functions

 setCustomErrorHandler ()
 

Function Documentation

◆ setCustomErrorHandler()

setCustomErrorHandler ( )

Copyright © Magento, Inc. All rights reserved. See COPYING.txt for license details.Set custom error handler.

Definition at line 10 of file error_handler.php.

11 {
12  set_error_handler(
13  function ($errNo, $errStr, $errFile, $errLine) {
14  if (error_reporting()) {
15  $errorNames = [
16  E_ERROR => 'Error',
17  E_WARNING => 'Warning',
18  E_PARSE => 'Parse',
19  E_NOTICE => 'Notice',
20  E_CORE_ERROR => 'Core Error',
21  E_CORE_WARNING => 'Core Warning',
22  E_COMPILE_ERROR => 'Compile Error',
23  E_COMPILE_WARNING => 'Compile Warning',
24  E_USER_ERROR => 'User Error',
25  E_USER_WARNING => 'User Warning',
26  E_USER_NOTICE => 'User Notice',
27  E_STRICT => 'Strict',
28  E_RECOVERABLE_ERROR => 'Recoverable Error',
29  E_DEPRECATED => 'Deprecated',
30  E_USER_DEPRECATED => 'User Deprecated',
31  ];
32 
33  $errName = isset($errorNames[$errNo]) ? $errorNames[$errNo] : "";
34 
35  throw new \PHPUnit\Framework\Exception(
36  sprintf("%s: %s in %s:%s.", $errName, $errStr, $errFile, $errLine),
37  $errNo
38  );
39  }
40  }
41  );
42 }