Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ErrorHandler.php
Go to the documentation of this file.
1 <?php
7 namespace Magento\Framework\App;
8 
13 {
19  protected $errorPhrases = [
20  E_ERROR => 'Error',
21  E_WARNING => 'Warning',
22  E_PARSE => 'Parse Error',
23  E_NOTICE => 'Notice',
24  E_CORE_ERROR => 'Core Error',
25  E_CORE_WARNING => 'Core Warning',
26  E_COMPILE_ERROR => 'Compile Error',
27  E_COMPILE_WARNING => 'Compile Warning',
28  E_USER_ERROR => 'User Error',
29  E_USER_WARNING => 'User Warning',
30  E_USER_NOTICE => 'User Notice',
31  E_STRICT => 'Strict Notice',
32  E_RECOVERABLE_ERROR => 'Recoverable Error',
33  E_DEPRECATED => 'Deprecated Functionality',
34  E_USER_DEPRECATED => 'User Deprecated Functionality',
35  ];
36 
47  public function handler($errorNo, $errorStr, $errorFile, $errorLine)
48  {
49  if (strpos($errorStr, 'DateTimeZone::__construct') !== false) {
50  // there's no way to distinguish between caught system exceptions and warnings
51  return false;
52  }
53 
54  $errorNo = $errorNo & error_reporting();
55  if ($errorNo == 0) {
56  return false;
57  }
58 
59  $msg = isset($this->errorPhrases[$errorNo]) ? $this->errorPhrases[$errorNo] : "Unknown error ({$errorNo})";
60  $msg .= ": {$errorStr} in {$errorFile} on line {$errorLine}";
61  throw new \Exception($msg);
62  }
63 }
handler($errorNo, $errorStr, $errorFile, $errorLine)