2

I am currently coding pages that will be executed by cronjobs so no real users will have access to them. In development I am using Whoops to debug my errors/exceptions.

I am not using Laravel any another framework. When I commit my code to the production environment how can I email these errors/exceptions to myself, instead of them being handled by Whoops which no one will be able to see anyway?

All I currently do is initiate Whoops

$whoops = new WhoopsRun();
$handler = new WhoopsPrettyPageHandler();
$whoops->pushHandler($handler)->register();
itsliamoco
  • 1,028
  • 1
  • 12
  • 28

1 Answers1

1

You would want to use a callback handler.

$whoops = new WhoopsRun();
$handler = new WhoopsCallbackHandler(function($exception, $inspector, $run) {
    //send an email
});
$whoops->pushHandler($handler)->register();

It looks like you are using use statement aliases so I matched your format, but the class is called Whoops\Handler\CallbackHandler.

Matt A
  • 1,096
  • 6
  • 6