/** * Handle exceptions * @param $exception */ public function handleException($exception) { if ($this->getRollbar()->enabled) { \Rollbar::report_exception($exception); } parent::handleException($exception); }
/** * Handles & reports uncaught PHP exceptions. */ public function handleException($exception) { if (!($exception instanceof \yii\web\HttpException and $exception->statusCode == 404)) { \Rollbar::report_exception($exception); } parent::handleException($exception); }
public function exception($exception, $extraData = NULL, $payloadData = NULL) { if (!is_a($exception, BASE_EXCEPTION)) { throw new \Exception(sprintf('Report exception requires an instance of %s.', BASE_EXCEPTION)); } \Rollbar::report_exception($exception, $extraData, $payloadData); }
public function onBootstrap(MvcEvent $e) { $application = $e->getApplication(); $eventManager = $application->getEventManager(); $serviceManager = $application->getServiceManager(); $config = $serviceManager->get('Config'); if (!isset($config['eye4web']['zf2rollbar'])) { throw new \Exception('Rollbar configuration missing. Please copy .dist config file into your autoloader directory.'); } $rollbarConfig = $config['eye4web']['zf2rollbar']; if ($serviceManager->has('zfcuser_auth_service')) { $authService = $serviceManager->get('zfcuser_auth_service'); if ($authService->hasIdentity()) { $user = $authService->getIdentity(); $rollbarConfig['person'] = ['id' => $user->getId(), 'email' => $user->getEmail(), 'username' => $user->getDisplayName()]; } } \Rollbar::init($rollbarConfig, $set_exception_handler = false, $set_error_handler = true); $eventManager->attach('dispatch.error', function ($event) { $exception = $event->getResult()->exception; if ($exception) { \Rollbar::report_exception($exception); } }); $eventManager->attach('render.error', function ($event) { $exception = $event->getResult()->exception; if ($exception) { \Rollbar::report_exception($exception); } }); }
protected function handleException($exception) { if (!($exception instanceof CHttpException && $exception->statusCode == 404)) { Rollbar::report_exception($exception); } parent::handleException($exception); }
/** * @inheritdoc */ protected function handleException($exception) { $ignored = is_callable($this->ignoreException) && call_user_func($this->ignoreException, $exception); if (!$ignored) { \Rollbar::report_exception($exception); } parent::handleException($exception); }
public function testExceptionBeforeInit() { $uuid = null; try { throw new Exception("test exception"); } catch (Exception $e) { $uuid = Rollbar::report_exception($e); } $this->assertNull($uuid); }
/** * Report or log an exception. * * This is a great spot to send exceptions to Sentry, Bugsnag, etc. * * @param \Exception $e * * @return void */ public function report(Exception $e) { parent::report($e); if (app()->environment() === 'local') { return; } if ($this->isHttpException($e)) { return; } \Rollbar::init(['environment' => app()->environment()]); \Rollbar::report_exception($e); }
/** * Initialize Rollbar. */ public function init() { // Require Rollbar vendor code require_once __DIR__ . '/vendor/autoload.php'; // Initialize Rollbar \Rollbar::init(array('access_token' => craft()->config->get('accessToken', 'rollbar'), 'environment' => CRAFT_ENVIRONMENT), false, false); // Log Craft Exceptions to Rollbar craft()->onException = function ($event) { \Rollbar::report_exception($event->exception); }; // Log Craft Errors to Rollbar craft()->onError = function ($event) { \Rollbar::report_message($event->message); }; }
function main() { $config = array('access_token' => 'ad865e76e7fb496fab096ac07b1dbabb', 'environment' => 'test', 'root' => '/Users/brian/www/rollbar-php', 'logger' => new EchoLogger(), 'error_sample_rates' => array(E_NOTICE => 0.5, E_USER_ERROR => 1, E_USER_NOTICE => 0.5), 'person_fn' => 'get_current_person', 'included_errno' => E_USER_ERROR | E_USER_NOTICE); // $config, $set_exception_handler, $set_error_handler Rollbar::init($config, true, true); try { throw_test_exception("yo"); } catch (Exception $e) { Rollbar::report_exception($e); } Rollbar::report_message("hey there", "info"); Rollbar::report_message("hey there", "info", array("extra" => "data"), array("fingerprint" => "test fingerprint", "title" => "test title")); trigger_error("test user warning", E_USER_WARNING); trigger_error("test user notice", E_USER_NOTICE); trigger_error("test user error", E_USER_ERROR); // raises an E_NOTICE, reported by the error handler $foo = $bar2; // reported by the exception handler throw new Exception("uncaught exception"); }