diff options
Diffstat (limited to 'stator')
-rw-r--r-- | stator/models.py | 5 | ||||
-rw-r--r-- | stator/runner.py | 7 |
2 files changed, 11 insertions, 1 deletions
diff --git a/stator/models.py b/stator/models.py index df385dd..a84f8c2 100644 --- a/stator/models.py +++ b/stator/models.py @@ -4,6 +4,7 @@ import traceback from typing import ClassVar, List, Optional, Type, Union, cast from asgiref.sync import sync_to_async +from django.conf import settings from django.db import models, transaction from django.utils import timezone from django.utils.functional import classproperty @@ -154,6 +155,10 @@ class StatorModel(models.Model): next_state = await current_state.handler(self) except BaseException as e: await StatorError.acreate_from_instance(self, e) + if settings.SENTRY_ENABLED: + from sentry_sdk import capture_exception + + capture_exception(e) traceback.print_exc() else: if next_state: diff --git a/stator/runner.py b/stator/runner.py index d286bc1..ed459be 100644 --- a/stator/runner.py +++ b/stator/runner.py @@ -5,6 +5,7 @@ import traceback import uuid from typing import List, Optional, Type +from django.conf import settings from django.utils import timezone from stator.models import StatorModel @@ -90,7 +91,11 @@ class StatorRunner: f"Attempting transition on {instance._meta.label_lower}#{instance.pk} from state {instance.state}" ) await instance.atransition_attempt() - except BaseException: + except BaseException as e: + if settings.SENTRY_ENABLED: + from sentry_sdk import capture_exception + + capture_exception(e) traceback.print_exc() def remove_completed_tasks(self): |