1818from framework .celery_tasks import app as celery_app
1919
2020from website import settings
21- from osf .models import Embargo , Registration , NodeLog
21+ from osf .models import Embargo , Registration
2222
2323from scripts import utils as scripts_utils
2424
@@ -59,12 +59,22 @@ def main(dry_run=True):
5959 embargo .accept ()
6060 transaction .savepoint_commit (sid )
6161 except Exception as err :
62+ root = parent_registration ._dirty_root
63+ embargo = root .embargo
64+
6265 logger .error (
6366 f'Unexpected error raised when activating embargo for '
64- f'registration { parent_registration ._id } . Continuing...'
67+ f'registration { parent_registration ._id } . Error: { err } ' ,
68+ exc_info = err ,
69+ extra = {
70+ 'is_public' : root .is_public ,
71+ 'approval_stage' : embargo .approval_stage .name ,
72+ 'is_approved' : root .embargo .is_approved
73+ }
6574 )
6675 logger .exception (err )
67- sentry .log_message (str (err ))
76+ sentry .log_exception (err )
77+
6878 transaction .savepoint_rollback (sid )
6979
7080 active_embargoes = Embargo .objects .filter (state = Embargo .APPROVED )
@@ -89,11 +99,21 @@ def main(dry_run=True):
8999 parent_registration .terminate_embargo ()
90100 transaction .savepoint_commit (sid )
91101 except Exception as err :
102+ root = parent_registration ._dirty_root
103+ embargo = root .embargo
104+
92105 logger .error (
93106 f'Registration { parent_registration ._id } could not be made public because { str (err )} ' ,
94- exc_info = err
107+ exc_info = err ,
108+ extra = {
109+ 'is_public' : root .is_public ,
110+ 'approval_stage' : embargo .approval_stage .name ,
111+ 'is_approved' : root .embargo .is_approved
112+ }
95113 )
96- sentry .log_message (f'Registration { parent_registration ._id } could not be made public because { str (err )} ' )
114+ logger .exception (err )
115+ sentry .log_exception (err )
116+
97117 transaction .savepoint_rollback (sid )
98118
99119
0 commit comments