{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","settings":"","params":[],"results":{"codes":[]}},"next":{"description":"","pages":[]},"title":"Error Handler","type":"basic","slug":"supporting-structure-error-handler","excerpt":"","body":"# Error Handler\n\nIt's easy to handle error/exception, find ``error_handler`` inside **project-name/config/app.php**, by default it should be like this:\n\n```php\n    'error_handler' => Components\\Exceptions\\Handler::class,\n```\n\nThe config above points to the components excception class, let's check that file go to **project-name/components/Exceptions/Handler.php**.\n\nNow let's dig into that class file, we have two(2) functions which it are ``report()`` and ``render($e)``.\n\nUnder ``report()`` function, we're calling the extended parent class, in which we call these PHP Native Functions ``register_shutdown_function()``, ``set_error_handler()`` and ``set_exception_handler()``.\n\nUnder ``render($e)`` function, we have plenty of ``if`` statement that checks the class instance of variable ``$e``, such example:\n\n```php\n        if ($e instanceof AccessNotAllowedException) {\n            return (new CsrfHandler)->handle($e);\n        }\n```\n\nThe code above passed-in the variable ``$e`` under ``CsrfHandler`` class, which you could also check how it prints out the error.","updates":[],"order":0,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"56e26e3a8d79b50e0031d8f6","createdAt":"2016-03-11T07:05:30.297Z","parentDoc":null,"__v":3,"project":"56c111095abfe40d00be875a","user":"56c1105874f0b417004baadc","category":{"sync":{"isSync":false,"url":""},"pages":["56e26e3a8d79b50e0031d8f6","56e26e42353e060e00b96826","56e26e4d95d1c60e00a969db","56e26e555ab0871700957c04","56e26e6f5ab0871700957c06","56e26e7d7d54ba0e004635a3","56e26e85353e060e00b96828"],"title":"Supporting Structure","slug":"supporting-structure","order":3,"from_sync":false,"reference":false,"_id":"56c42826c0c4630d004e86cb","__v":7,"createdAt":"2016-02-17T07:58:30.542Z","project":"56c111095abfe40d00be875a","version":"56c111095abfe40d00be875d"},"githubsync":"","version":{"version":"1.3.0","version_clean":"1.3.0","codename":"","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["56c1110a5abfe40d00be875e","56c413a254b6030d00ec299d","56c4275048213b1700af6e33","56c42826c0c4630d004e86cb","56c4282cbc41330d009f2607","56c4284ad1f6d91700d3697e","56e271c195d1c60e00a969ee"],"_id":"56c111095abfe40d00be875d","releaseDate":"2016-02-14T23:43:05.566Z","__v":7,"createdAt":"2016-02-14T23:43:05.566Z","project":"56c111095abfe40d00be875a"}}
# Error Handler It's easy to handle error/exception, find ``error_handler`` inside **project-name/config/app.php**, by default it should be like this: ```php 'error_handler' => Components\Exceptions\Handler::class, ``` The config above points to the components excception class, let's check that file go to **project-name/components/Exceptions/Handler.php**. Now let's dig into that class file, we have two(2) functions which it are ``report()`` and ``render($e)``. Under ``report()`` function, we're calling the extended parent class, in which we call these PHP Native Functions ``register_shutdown_function()``, ``set_error_handler()`` and ``set_exception_handler()``. Under ``render($e)`` function, we have plenty of ``if`` statement that checks the class instance of variable ``$e``, such example: ```php if ($e instanceof AccessNotAllowedException) { return (new CsrfHandler)->handle($e); } ``` The code above passed-in the variable ``$e`` under ``CsrfHandler`` class, which you could also check how it prints out the error.