Got Error Intimation before your user will frustrate(Laravel)
OVERVIEW
Today I am going to talk about the situation when user will face error and our backend team will wait for getting screen shot or scenerio from our user at which he faced the issue and then our team will solve it.
Although it is the wishlist of every developer that his code will not fail at any moment, but still after moving to production some times we may face the situation where error comes, to solve this i am using Email intimation of error using Laravel’s Exception Handler.
Setup
Lets start the task by moving to app/Exceptions/Handler.php File
put
use Exception;
at top of your Handler.php file
then use parameter “Exception $exception” to your render()
then render function will look like-
render(Exception $exception)
Now add the below code in render(Exception $exception)
now you will recieve an email every time user will face error. Your email will contain the information about
Error File
Error Line No.
Error Message
and other parameters if user is log in we have passed username also for our information and we are also tracking ip address of user.
In this way we can get intimation of error which our user is facing.
Please feel free to comment if you have any question about this topic.