php - Error and exception handling in php7 -
recently moved php7. following error occurs:
argument 1 passed myclass\throwable::exceptionhandler() must instance of exception, instance of error given and respective class
namespace myclass; class throwable { public function exceptionhandler(\exception $exception) { //logic here } } as stated in docs
most errors reported throwing error exceptions.
does mean have provide instance of error or more general throwable exception handler?
errors , exceptions both extend throwable errors not extended exception.
therefore, exceptionhandler must accept object of type throwable in order accept errors.
simplest fix this, though may want rename $exception make clear.
namespace myclass; class throwable { public function exceptionhandler(\throwable $exception) { //logic here } } note: new error class should not confussed errorexception has classicly been used device turning php 5 errors exception objects symantic meaning.
Comments
Post a Comment