How to use the bugsnag.auto_notify function in bugsnag

To help you get started, we’ve selected a few bugsnag examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bugsnag / bugsnag-python / tests / test_notify.py View on Github external
def test_auto_notify_defaults(self):
        bugsnag.auto_notify(ScaryException("unexpected failover"))

        json_body = self.server.received[0]['json_body']
        event = json_body['events'][0]
        self.assertTrue(event['unhandled'])
        self.assertEqual(event['severity'], 'error')
        self.assertEqual(event['severityReason'], {
            "type": "unhandledException"
        })
github bugsnag / bugsnag-python / tests / test_notify.py View on Github external
def test_auto_notify_overrides(self):
        bugsnag.auto_notify(
            ScaryException("unexpected failover"),
            severity='info',
            unhandled=False,
            severity_reason={
                "type": "middleware_handler",
                "attributes": {
                    "name": "test middleware"
                }
            }
        )

        json_body = self.server.received[0]['json_body']
        event = json_body['events'][0]
        self.assertFalse(event['unhandled'])
        self.assertEqual(event['severity'], 'info')
        self.assertEqual(event['severityReason'], {
github bugsnag / bugsnag-python / bugsnag / wsgi / middleware.py View on Github external
def close(self):
        try:
            if hasattr(self.app, 'close'):
                return self.app.close()
        except Exception as e:
            bugsnag.auto_notify(
                e,
                severity_reason=self.SEVERITY_REASON
            )
            raise
        finally:
            bugsnag.clear_request_config()
github bugsnag / bugsnag-python / bugsnag / wsgi / middleware.py View on Github external
def __init__(self, application, environ, start_response):
        self.environ = environ

        bugsnag.configure_request(wsgi_environ=self.environ)

        try:
            if bugsnag.configuration.auto_capture_sessions:
                bugsnag.start_session()
            self.app = application(environ, start_response)
        except Exception as e:
            bugsnag.auto_notify(
                e,
                severity_reason=self.SEVERITY_REASON
            )
            raise
github bugsnag / bugsnag-python / bugsnag / tornado / __init__.py View on Github external
"attributes": {
                    "framework": "Tornado"
                }
            }
        }

        # Notify bugsnag, unless it's an HTTPError that we specifically want
        # to ignore
        should_notify_bugsnag = True
        if type(exc) == HTTPError:
            ignore_status_codes = self.bugsnag_ignore_status_codes()
            if ignore_status_codes and exc.status_code in ignore_status_codes:
                should_notify_bugsnag = False

        if should_notify_bugsnag:
            bugsnag.auto_notify(exc, **options)

        # Call the parent handler
        RequestHandler._handle_request_exception(self, exc)
github bugsnag / bugsnag-python / bugsnag / flask / __init__.py View on Github external
def __log_exception(sender, exception, **extra):
    bugsnag.auto_notify(exception, severity_reason={
        "type": "unhandledExceptionMiddleware",
        "attributes": {
            "framework": "Flask"
        }
github bugsnag / bugsnag-python / bugsnag / celery / __init__.py View on Github external
def failure_handler(sender, task_id, exception, args, kwargs, traceback, einfo,
                    **kw):
    task = {
        "task_id": task_id,
        "args": args,
        "kwargs": kwargs
    }

    bugsnag.auto_notify(exception, traceback=traceback,
                        context=sender.name,
                        extra_data=task,
                        severity_reason={
                            'type': 'unhandledExceptionMiddleware',
                            'attributes': {
                                'framework': 'Celery'
                            }
github bugsnag / bugsnag-python / bugsnag / django / middleware.py View on Github external
def process_exception(self, request, exception):
        try:
            bugsnag.auto_notify(
                exception,
                severity_reason={
                    "type": "unhandledExceptionMiddleware",
                    "attributes": {
                        "framework": "Django"
                    }
                }
            )

        except Exception:
            bugsnag.logger.exception("Error in exception middleware")

        bugsnag.clear_request_config()

        return None