obs_operator: override HTTPServer.handle_error() to capture exceptions.

This commit is contained in:
Jimmy Berry 2019-08-29 14:36:01 -05:00
parent d10a359c0c
commit 3a2aed7f33

View File

@ -27,9 +27,13 @@ from urllib.parse import parse_qs
# https://stackoverflow.com/a/47012250, workaround by making EVERYTHING LEGAL! # https://stackoverflow.com/a/47012250, workaround by making EVERYTHING LEGAL!
http.cookies._is_legal_key = lambda _: True http.cookies._is_legal_key = lambda _: True
sentry_sdk = sentry_init()
# Available in python 3.7. # Available in python 3.7.
class ThreadedHTTPServer(ThreadingMixIn, HTTPServer): class ThreadedHTTPServer(ThreadingMixIn, HTTPServer):
pass def handle_error(self, request, client_address):
super().handle_error(request, client_address)
sentry_sdk.capture_exception()
class RequestHandler(BaseHTTPRequestHandler): class RequestHandler(BaseHTTPRequestHandler):
COOKIE_NAME = 'openSUSE_session' # Both OBS and IBS. COOKIE_NAME = 'openSUSE_session' # Both OBS and IBS.
@ -361,7 +365,7 @@ class OSCRequestEnvironmentException(Exception):
def main(args): def main(args):
conf.get_config() # Allow sentry DSN to be available. conf.get_config() # Allow sentry DSN to be available.
sentry_init() sentry_sdk = sentry_init()
RequestHandler.apiurl = args.apiurl RequestHandler.apiurl = args.apiurl
RequestHandler.session = args.session RequestHandler.session = args.session