This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
I want to send all errors via email, while at the same time continuing to do the default error behavior - any idea on the best way to do that?
it looks like the best way to do this is to add the following to the boot method of a plugin:
App::error(function(RuntimeException $exception) {
Mail::send('error-message', ["error" => var_dump($exception)], function($message) use($email, $full_name) {
});
// Handle the exception...
});
source: http://octobercms.com/docs/services/error-log
However if I do that, then the error message does not display in the browser.. I want it to continue to display so I can properly debug the message, but if it helps to also have it emailed so I can investigate it if I don't see it.
Any ideas?
Thanks!
Update 5/12/2016:
Ha, I think I was confused about this. Handling the error does not stop the default behavior of rendering the error on screen UNLESS you return some value, in which case that value is displayed on the screen.
However, I see with my above code, it's not sufficient to catch all errors. If I was going to implement this today, I would use additionally create error handlers for "Exception", "ApplicationException", "SystemException", "ValidationException"
e.g.
App::error(function(SystemException $exception) { ... });
Also, I am more aware of the dangers of using email for this purpose.. If there are a lot of errors, you could end up getting too many emails for your system to process. If you're forwarding these emails to something like slack, slack will reject that email, and if you're using something like mandrill to send email, your reputation could be affected.
In the future I'd probably use a proper error tracking application like bugsnag.
Last updated
1-1 of 1