/** * @param GetResponseForExceptionEvent|ConsoleExceptionEvent $event */ public function onKernelException($event) { $exception = $event->getException(); foreach ($this->ignoredExceptions as $ignoredException) { if ($exception instanceof $ignoredException) { return; } } $this->notifier->notify($exception); }
/** * 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; } if (!($error['type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR))) { return; } $this->notifier->notify(new \ErrorException($error['message'], $error['type'], $error['type'], $error['file'], $error['line'])); }
/** * @param array $notice * @return array|null */ public function sendNotice(array $notice) { if (!$this->isEnabled()) { return null; } $result = $this->client->sendNotice($notice); if (!is_array($result)) { return null; } return $result; }
/** * {@inheritdoc} */ protected function write(array $record) { $trace = array_slice(debug_backtrace(), 3); $exc = new Errors\Base($record['message'], $trace); $notice = $this->notifier->buildNotice($exc); $type = $record['channel'] . '.' . $record['level_name']; $notice['errors'][0]['type'] = $type; if (!empty($record['context'])) { $notice['params']['monolog_context'] = $record['context']; } if (!empty($record['extra'])) { $notice['params']['monolog_extra'] = $record['extra']; } return $this->notifier->sendNotice($notice); }
/** * Register the application services. * * @return void */ public function register() { $this->app->singleton('Airbrake\\Instance', function ($app) { $airbrake = new Notifier(['projectId' => config('airbrake.id'), 'projectKey' => config('airbrake.key'), 'host' => config('airbrake.host')]); $airbrake->addFilter(function ($notice) { $this->setEnvName($notice); foreach ($this->getEnvKeys() as $envKey) { $this->filterEnvKey($notice, $envKey); } return $notice; }); return $airbrake; }); $handler = $this->app->make('Illuminate\\Contracts\\Debug\\ExceptionHandler'); $this->app->instance('Illuminate\\Contracts\\Debug\\ExceptionHandler', new Handler\AirbrakeExceptionHandler($handler, $this->app)); }