Error handler is back


(Alexander Makarov) #1

I’ve ported over error handler from Yii 2 keeping most features and improving some.

It converts warnings, notices etc. to exceptions as it was in Yii 2:

It handles fatals such as parsing errors:

It handles out of memory:

Of course, it handles normal exceptions:

If request context is available, it gives info about request. The format is ready to copy-paste to PhpStorm editor-based HTTP client.

It logs:

2019-07-09 21:56:43.770100 [error][application] ErrorException (Warning) with message 'Division by zero' 

in D:\dev\yii-dev\dev\yii-demo\src\Controller\SiteController.php:28

Stack trace:
#0 D:\dev\yii-dev\dev\yii-demo\src\Controller\SiteController.php(28): Yiisoft\Yii\Web\ErrorHandler\ErrorHandler->handleError(2, 'Division by zer...', 'D:\\dev\\yii-dev\\...', 28, Array)
#1 D:\dev\yii-dev\dev\injector\src\Injector.php(53): App\Controller\SiteController->index(Object(Nyholm\Psr7\ServerRequest), Object(Yiisoft\Yii\Web\MiddlewareDispatcher))
#2 D:\dev\yii-dev\dev\yii-web\src\Middleware\ActionCaller.php(33): Yiisoft\Injector\Injector->invoke(Array, Array)
#3 D:\dev\yii-dev\dev\router\src\Route.php(259): Yiisoft\Yii\Web\Middleware\ActionCaller->process(Object(Nyholm\Psr7\ServerRequest), Object(Yiisoft\Yii\Web\MiddlewareDispatcher))
#4 D:\dev\yii-dev\dev\router\src\MatchingResult.php(57): Yiisoft\Router\Route->process(Object(Nyholm\Psr7\ServerRequest), Object(Yiisoft\Yii\Web\MiddlewareDispatcher))
#5 D:\dev\yii-dev\dev\router\src\Middleware\Router.php(31): Yiisoft\Router\MatchingResult->process(Object(Nyholm\Psr7\ServerRequest), Object(Yiisoft\Yii\Web\MiddlewareDispatcher))
#6 D:\dev\yii-dev\dev\yii-web\src\MiddlewareDispatcher.php(72): Yiisoft\Router\Middleware\Router->process(Object(Nyholm\Psr7\ServerRequest), Object(Yiisoft\Yii\Web\MiddlewareDispatcher))
#7 D:\dev\yii-dev\dev\yii-web\src\Middleware\ErrorCatcher.php(76): Yiisoft\Yii\Web\MiddlewareDispatcher->handle(Object(Nyholm\Psr7\ServerRequest))
#8 D:\dev\yii-dev\dev\yii-web\src\MiddlewareDispatcher.php(72): Yiisoft\Yii\Web\Middleware\ErrorCatcher->process(Object(Nyholm\Psr7\ServerRequest), Object(Yiisoft\Yii\Web\MiddlewareDispatcher))
#9 D:\dev\yii-dev\dev\yii-web\src\Application.php(47): Yiisoft\Yii\Web\MiddlewareDispatcher->handle(Object(Nyholm\Psr7\ServerRequest))
#10 D:\dev\yii-dev\dev\yii-demo\public\index.php(23): Yiisoft\Yii\Web\Application->run()
#11 D:\dev\yii-dev\dev\yii-demo\public\index.php(24): {closure}()
#12 {main}

(Mehdi Achour) #2

Nice!

A copy as cURL would be a nice addition too for the http thing.


(Alexander Makarov) #3

I’m not using CURL much except simple requests so not familiar with exact syntax :frowning:


(Stefano Mtangoo) #4

(Alexander Makarov) #5

(Alexander Makarov) #6