When to use ErrorException vs Exception?

前端 未结 1 1856
闹比i
闹比i 2021-02-19 08:58

PHP 5.1 has introduced ErrorException. The constructor of the two functions differs

public __construct ([ string $message = \"\" [, int $code = 0 [, Exception $p         


        
相关标签:
1条回答
  • 2021-02-19 09:33

    ErrorException is mostly used to convert php error (raised by error_reporting) to Exception.

    You should avoid using directly Exception which is too wide. Subclass it with specific Exception or use predefined SPL Exception

    To follow your edit : Yes extends Exception rather than ErrorException.

    0 讨论(0)
提交回复
热议问题