diff --git a/openlibrary/accounts/model.py b/openlibrary/accounts/model.py index 0318b46d810..b0623444c74 100644 --- a/openlibrary/accounts/model.py +++ b/openlibrary/accounts/model.py @@ -689,7 +689,9 @@ def create( return ia_account elif 'screenname' not in response.get('values', {}): - raise OLAuthenticationError('undefined_error') + error = OLAuthenticationError('undefined_error') + error.response = response + raise error elif attempt >= retries: e = OLAuthenticationError('username_registered') diff --git a/openlibrary/plugins/upstream/account.py b/openlibrary/plugins/upstream/account.py index be8772ba57a..17c89418e31 100644 --- a/openlibrary/plugins/upstream/account.py +++ b/openlibrary/plugins/upstream/account.py @@ -328,7 +328,8 @@ def POST(self): from openlibrary.plugins.openlibrary.sentry import sentry if sentry.enabled: - sentry.capture_exception(e) + extra = {'response': e.response} if hasattr(e, 'response') else None + sentry.capture_exception(e, extras=extra) return render['account/create'](f) diff --git a/openlibrary/utils/sentry.py b/openlibrary/utils/sentry.py index 438da403ab1..0b549fae0b9 100644 --- a/openlibrary/utils/sentry.py +++ b/openlibrary/utils/sentry.py @@ -87,8 +87,11 @@ def capture_exception_webpy(self): scope.add_event_processor(add_web_ctx_to_event) sentry_sdk.capture_exception() - def capture_exception(self, ex): + def capture_exception(self, ex, extras: dict | None = None): with sentry_sdk.push_scope() as scope: + if extras: + for key, value in extras.items(): + scope.set_extra(key, value) scope.add_event_processor(add_web_ctx_to_event) sentry_sdk.capture_exception(ex)