Skip to content

Commit

Permalink
Send email notifications when an unhandled exception happened
Browse files Browse the repository at this point in the history
  • Loading branch information
humitos committed Jun 11, 2018
1 parent 04ce7bb commit 2fec3a6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions readthedocs/projects/tasks.py
Expand Up @@ -326,12 +326,18 @@ def run(self, pk, version_pk=None, build_pk=None, record=True,
'An unhandled exception was raised during build setup',
extra={'tags': {'build': build_pk}}
)
# FIXME: ``self.setup_env`` is created inside the ``self.run_setup``
# so, if the exception ocurrs before this call or inside it but
# before creating the ``self.setup_env`` this ``except`` block will
# also fail
self.setup_env.failure = BuildEnvironmentError(
BuildEnvironmentError.GENERIC_WITH_BUILD_ID.format(
build_id=build_pk,
)
)
self.setup_env.update_build(BUILD_STATE_FINISHED)
# Send notifications for unhandled errors
self.send_notifications()
return False
else:
# No exceptions in the setup step, catch unhandled errors in the
Expand All @@ -343,12 +349,17 @@ def run(self, pk, version_pk=None, build_pk=None, record=True,
'An unhandled exception was raised during project build',
extra={'tags': {'build': build_pk}}
)
# FIXME: ``self.build_env`` is created inside the
# ``self.run_build`` so, if the exception ocurrs before this
# variable is created this ``except`` block will also fail
self.build_env.failure = BuildEnvironmentError(
BuildEnvironmentError.GENERIC_WITH_BUILD_ID.format(
build_id=build_pk,
)
)
self.build_env.update_build(BUILD_STATE_FINISHED)
# Send notifications for unhandled errors
self.send_notifications()
return False

return True
Expand Down

0 comments on commit 2fec3a6

Please sign in to comment.