|
| 1 | +<?php |
| 2 | +//---------------------------------------------------------------------------------------------------------------------- |
| 3 | +namespace SetBased\Exception; |
| 4 | + |
| 5 | +//---------------------------------------------------------------------------------------------------------------------- |
| 6 | +/** |
| 7 | + * Class for PHP errors. |
| 8 | + */ |
| 9 | +class ErrorException extends \ErrorException implements NamedException |
| 10 | +{ |
| 11 | + protected static $ourNames = [E_COMPILE_ERROR => 'PHP Compile Error', |
| 12 | + E_COMPILE_WARNING => 'PHP Compile Warning', |
| 13 | + E_CORE_ERROR => 'PHP Core Error', |
| 14 | + E_CORE_WARNING => 'PHP Core Warning', |
| 15 | + E_DEPRECATED => 'PHP Deprecated Warning', |
| 16 | + E_ERROR => 'PHP Fatal Error', |
| 17 | + E_NOTICE => 'PHP Notice', |
| 18 | + E_PARSE => 'PHP Parse Error', |
| 19 | + E_RECOVERABLE_ERROR => 'PHP Recoverable Error', |
| 20 | + E_STRICT => 'PHP Strict Warning', |
| 21 | + E_USER_DEPRECATED => 'PHP User Deprecated Warning', |
| 22 | + E_USER_ERROR => 'PHP User Error', |
| 23 | + E_USER_NOTICE => 'PHP User Notice', |
| 24 | + E_USER_WARNING => 'PHP User Warning', |
| 25 | + E_WARNING => 'PHP Warning']; |
| 26 | + |
| 27 | + //-------------------------------------------------------------------------------------------------------------------- |
| 28 | + /** |
| 29 | + * {@inheritdoc} |
| 30 | + */ |
| 31 | + public function getName() |
| 32 | + { |
| 33 | + return isset(self::$ourNames[$this->getCode()]) ? self::$ourNames[$this->getCode()] : 'Error'; |
| 34 | + } |
| 35 | + |
| 36 | + //-------------------------------------------------------------------------------------------------------------------- |
| 37 | +} |
| 38 | + |
| 39 | +//---------------------------------------------------------------------------------------------------------------------- |
0 commit comments