/** * @param Exception $e */ public function report(Exception $e) { $config = new Configuration(env('AIRBRAKE_API_KEY')); $client = new Client($config); $client->notifyOnException($e); return parent::report($e); }
function it_reports_exceptions() { // Arrange. $exception = new UnexpectedValueException(); $extra = ['php' => 'wins']; // Act. $this->report($exception, $extra); // Assert. $this->airbrake->notifyOnException($exception, $extra)->shouldHaveBeenCalled(); }
/** * @param GetResponseForExceptionEvent $event */ public function onKernelException(GetResponseForExceptionEvent $event) { $exception = $event->getException(); foreach ($this->ignoredExceptions as $ignoredException) { if ($exception instanceof $ignoredException) { return; } } $this->client->notifyOnException($exception); error_log('ERRBIT: ' . $exception->getMessage() . ' in: ' . $exception->getFile() . ':' . $exception->getLine()); }
/** * Handles the PHP shutdown event. * * This event exists almost solely to provide a means to catch and log errors that might have been * otherwise lost when PHP decided to die unexpectedly. */ public function onShutdown() { // Get the last error if there was one, if not, let's get out of here. if (!($error = error_get_last())) { return; } $fatal = array(E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR); if (!in_array($error['type'], $fatal)) { return; } $message = '[Shutdown Error]: %s'; $message = sprintf($message, $error['message']); $backtrace = array(array('file' => $error['file'], 'line' => $error['line'])); $this->client->notifyOnError($message, $backtrace); error_log($message . ' in: ' . $error['file'] . ':' . $error['line']); }
/** * Handles the PHP shutdown event. * * This event exists almost soley to provide a means to catch and log errors that might have been * otherwise lost when PHP decided to die unexpectedly. */ public function onShutdown() { // If the instance was unset, then we shouldn't run. if (self::$instance == null) { return; } // This will help prevent multiple calls to this, incase the shutdown handler was declared // multiple times. This only should occur in unit tests, when the handlers are created // and removed repeatedly. As we cannot remove shutdown handlers, this prevents us from // calling it 1000 times at the end. self::$instance = null; // Get the last error if there was one, if not, let's get out of here. if (!($error = error_get_last())) { return; } // Don't notify on warning if not configured to. if (!$this->shouldNotifyError($error['type'], $error['message'], $error['file'], $error['line'])) { return; } // Build a fake backtrace, so we at least can show where we came from. $backtrace = array(array('file' => $error['file'], 'line' => $error['line'], 'function' => '', 'args' => array())); $this->airbrakeClient->notifyOnError('[Improper Shutdown] ' . $error['message'], $backtrace); }
/** * Class constructor * * @param Eo\AirbrakeBundle\Bridge\Configuration $configuration */ public function __construct(Configuration $configuration) { parent::__construct($configuration); }
public function notify(Notice $notice) { if ($this->enabled) { parent::notify($notice); } }
/** * @param \Exception $exception */ public static function log_exception(\Exception $exception) { if (self::$client instanceof \Airbrake\Client) { self::$client->notifyOnException($exception); } }
/** * Reports the exception to the SaaS platform * * @param Exception $e * @param array $extra * @return mixed */ public function report(Exception $e, array $extra = []) { return $this->airbrake->notifyOnException($e, $extra); }