Having errors and exceptions as two different error handling system introduces a certain level of confusion among developers. The older versions of PHP made it difficult to reason with E_ERROR
as they could not be caught with custom error handlers. The PHP 7 version tried to address this confusion by introducing the Throwable
interface, which is summarized as follows:
Throwable { abstract public string getMessage (void) abstract public int getCode (void) abstract public string getFile (void) abstract public int getLine (void) abstract public array getTrace (void) abstract public string getTraceAsString (void) abstract public Throwable getPrevious (void) abstract public string __toString (void) }
The Throwable
interface is now the base interface for Error
, Exception
, and any other object that can be thrown via a throw
statement. The methods defined in this interface are nearly identical to those of Exception
. The PHP classes themselves cannot implement...