I am looking to make error reporting from an app more friendly to users. I am going to replace the 'Whoops' screen (in production) with a form allowing the user to submit the problem. I am wondering if there is a simple way to add a specific ID# (unique integer) to the stack trace in the error log so that we can easily view specific errors which were generated on production.
The simple way to do this is in app/start/global.php. Under the Application Error Handler you want to log your error, and generate a GUID (or something similar).
App::error(function(Exception $exception, $code)
{
// Generate a unique ID for this error...
$unique_id = uniqid();
// log the error
Log::error(str_repeat('-', 40));
Log::error("Exception for $unique_id");
Log::error($exception);
// return error form
return View::make('whoops_error_form')->with('unique_id', $unique_id);
});
Your whoops_error_form template would have a hidden form somewhere where you will be able to submit the application error. All reports would be logged in app/storage/logs.
By returning the view on App::error, you will disable the other exception handlers (such as Whoops!)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With