PHP Predefined exception classes and interfaces
PHP have some predefined exception handling classes and interfaces, Which is used to handle different types exceptions.
There are the list of these classes are given:
-
Exception - Exception is the base class for all Exceptions in PHP 5, and the base class for all user exceptions in PHP 7.
-
ErrorException - An Error Exception.
-
Error - Error is the base class for all internal PHP errors.
-
ArgumentCountError - ArgumentCountError is thrown when too few arguments are passed to a user-defined function or method.
-
ArithmeticError - ArithmeticErroris thrown when an error occurs while performing mathematical operations.
-
AssertionError – AssertionError is thrown when an assertion made via assert() fails.
-
DivisionByZeroError – DivisionByZeroError is thrown when an attempt is made to divide a number by zero.
-
ParseError – ParseError is thrown when an error occurs while parsing PHP code, such as when eval() is called.
-
TypeError - There are three scenarios where a TypeError may be thrown. The first is where the argument type being passed to a function does not match its corresponding declared parameter type. The second is where a value being returned from a function does not match the declared function return type. The third is where an invalid number of arguments are passed to a built-in PHP function (strict mode only).
-
Throwable - Throwable is the base interface for any object that can be thrown via a throw statement in PHP 7, including Error and Exception.