0

Here is how i'm implementing Bugsnag in Zend framwork 2

public function onBootstrap(MvcEvent $e)
{
    $eventManager        = $e->getApplication()->getEventManager();
    $moduleRouteListener = new ModuleRouteListener();
    $eventManager->attach(
    'dispatch.error', function($event) {
        $error = $event->getError();
        if ($error == 'error-exception') {
            $exception = $event->getParam('exception');
            $bugsnag = Bugsnag\Client::make("MYKEY");
            Bugsnag\Handler::register($bugsnag);
            $bugsnag->notifyException($exception);
        }
    }
);
    $moduleRouteListener->attach($eventManager);
}

but its not working, The error is not processing What am i doing wrong.

Suneel Kumar
  • 1,650
  • 2
  • 21
  • 31
Waqar Haider
  • 929
  • 10
  • 33

1 Answers1

0
public function onBootstrap(MvcEvent $e)
{
    $application = $e->getApplication();
    $em = $application->getEventManager();
    //handle the dispatch error (exception) 
    $em->attach(\Zend\Mvc\MvcEvent::EVENT_DISPATCH_ERROR, array($this, 'handleError'));
    //handle the view render error (exception) 
    $em->attach(\Zend\Mvc\MvcEvent::EVENT_RENDER_ERROR, array($this, 'handleError'));
}

public function handleError(MvcEvent $e)
{
      if($e->getError() == 'error-exception'){
        $exception = $e->getParam('exception');
        $bugsnag = Bugsnag\Client::make("MYKEY");
        Bugsnag\Handler::register($bugsnag);
        $bugsnag->notifyException($exception);

    }
}
Waqar Haider
  • 929
  • 10
  • 33