Skip to content

Commit

Permalink
Merge pull request #5 from graze/whoopsHandlerBuubling
Browse files Browse the repository at this point in the history
Map Whoops->handle() responses to Monolog bubbling
  • Loading branch information
adlawson committed Aug 5, 2014
2 parents 2b05b23 + b22752c commit 15202b1
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/Graze/Monolog/Handler/WhoopsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

use Monolog\Handler\AbstractProcessingHandler;
use Monolog\Logger;
use Whoops\Handler\Handler;
use Whoops\Handler\HandlerInterface as WhoopsHandlerInterface;
use Whoops\Exception\ErrorException as WhoopsErrorException;
use Whoops\Exception\Inspector as WhoopsInspector;
Expand Down Expand Up @@ -79,13 +80,30 @@ protected function writeError(array $record)
* @param Exception $exception
*/
protected function writeException(\Exception $exception)
{
{
$whoopsInspector = new WhoopsInspector($exception);

$this->whoopsHandler->setInspector($whoopsInspector);
$this->whoopsHandler->setException($exception);
$this->whoopsHandler->setRun(new WhoopsRun);

echo $this->whoopsHandler->handle();
$whoopsHandleResponse = $this->whoopsHandler->handle();

$this->processWhoopsBubbling($whoopsHandleResponse);
}

/**
* Map Whoops->handle() responses to Monolog bubbling
*
* @param int $whoopsHandleResponse response as returned from Whoops\Handler\Handler::handle()
*/
protected function processWhoopsBubbling($whoopsHandleResponse)
{
switch ($whoopsHandleResponse) {
case Handler::LAST_HANDLER:
case Handler::QUIT:
// don't call further monolog handlers
$this->setBubble(false);
}
}
}

0 comments on commit 15202b1

Please sign in to comment.