From 16f6fe9d3b59a7e3113e59a4bbabc668fd7b08cd Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Mon, 2 Mar 2015 09:05:32 +0100 Subject: [PATCH] Send criticals errors to Sentry Fixes #77 --- gns3server/crash_report.py | 13 +++++++------ gns3server/main.py | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/gns3server/crash_report.py b/gns3server/crash_report.py index 44f96588..e70a0e55 100644 --- a/gns3server/crash_report.py +++ b/gns3server/crash_report.py @@ -38,16 +38,17 @@ class CrashReport: def __init__(self): self._client = None - def capture_exception(self, request): + def capture_exception(self, request=None): server_config = Config.instance().get_section_config("Server") if server_config.getboolean("report_errors"): if self._client is None: self._client = raven.Client(CrashReport.DSN, release=__version__) - self._client.http_context({ - "method": request.method, - "url": request.path, - "data": request.json, - }) + if request is not None: + self._client.http_context({ + "method": request.method, + "url": request.path, + "data": request.json, + }) try: self._client.captureException() except asyncio.futures.TimeoutError: diff --git a/gns3server/main.py b/gns3server/main.py index db0a9757..0d846445 100644 --- a/gns3server/main.py +++ b/gns3server/main.py @@ -178,7 +178,7 @@ def main(): server.run() except Exception as e: log.critical("Critical error while running the server: {}".format(e), exc_info=1) - # TODO: send exception to Sentry + CrashReport.instance().capture_exception() return if __name__ == '__main__':