-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Improve error reporting to users #3247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 15 commits
11022f7
e4330ef
e635ac6
2ddf48c
4bcfd40
0ef09df
4b9be39
17e6b94
8a4f380
858103b
e94959a
fab58c9
243f82a
17bf06d
3f8076f
64ce4b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -421,7 +421,11 @@ def update_build(self, state=None): | |
self.build['error'] = str(self.failure) | ||
else: | ||
self.build['error'] = ugettext_noop( | ||
"An unexpected error occurred") | ||
"A failure in our code has occured. " | ||
"Please report this to us with your build id ({}).".format( | ||
self.build['pk'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure best way to handle this. Interpolation on localized strings should happen outside |
||
) | ||
) | ||
|
||
# Attempt to stop unicode errors on build reporting | ||
for key, val in list(self.build.items()): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,20 +108,51 @@ def _log(self, msg): | |
version=self.version.slug, | ||
msg=msg)) | ||
|
||
# pylint: disable=arguments-differ | ||
def run(self, pk, version_pk=None, build_pk=None, record=True, | ||
docker=False, search=True, force=False, localmedia=True, **__): | ||
# pylint: disable=arguments-differ | ||
self.project = self.get_project(pk) | ||
self.version = self.get_version(self.project, version_pk) | ||
self.build = self.get_build(build_pk) | ||
self.build_search = search | ||
self.build_localmedia = localmedia | ||
self.build_force = force | ||
self.config = None | ||
""" | ||
Run a documentation build. | ||
|
||
setup_successful = self.run_setup(record=record) | ||
if setup_successful: | ||
self.run_build(record=record, docker=docker) | ||
This is fully wrapped in exception handling to account for a number of failure cases. | ||
""" | ||
try: | ||
self.project = self.get_project(pk) | ||
self.version = self.get_version(self.project, version_pk) | ||
self.build = self.get_build(build_pk) | ||
self.build_search = search | ||
self.build_localmedia = localmedia | ||
self.build_force = force | ||
self.config = None | ||
|
||
setup_successful = self.run_setup(record=record) | ||
if setup_successful: | ||
self.run_build(record=record, docker=docker) | ||
failure = self.setup_env.failure or self.build_env.failure | ||
except Exception as e: # noqa | ||
log.exception('Top-level build exception has been raised', extra={'build': build_pk}) | ||
failure = str(e) | ||
|
||
# **Always** report build status. | ||
# This can still fail if the API Is totally down, but should catch more failures | ||
result = {} | ||
error = 'Unknown error. Please include the build id ({}) in any bug reports.'.format( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
build_pk | ||
) | ||
if hasattr(self, 'build'): | ||
self.build['state'] = BUILD_STATE_FINISHED | ||
if failure: | ||
self.build['error'] = error | ||
self.build['success'] = False | ||
result = api_v2.build(build_pk).patch(self.build) | ||
else: | ||
build_updates = { | ||
'state': BUILD_STATE_FINISHED, | ||
'success': False, | ||
'error': error, | ||
} | ||
result = api_v2.build(build_pk).patch(build_updates) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reduce duplicated code to: if hasattr(self, 'build'):
build_updates = {...}
else:
build_updates = {...}
return api_v2.build(build_pk).patch(build_updates) |
||
return result | ||
|
||
def run_setup(self, record=True): | ||
"""Run setup in the local environment. | ||
|
@@ -166,7 +197,6 @@ def run_setup(self, record=True): | |
if not isinstance(self.setup_env.failure, vcs_support_utils.LockTimeout): | ||
self.send_notifications() | ||
|
||
self.setup_env.update_build(state=BUILD_STATE_FINISHED) | ||
return False | ||
|
||
if self.setup_env.successful and not self.project.has_valid_clone: | ||
|
@@ -230,14 +260,11 @@ def run_build(self, docker=False, record=True): | |
self.send_notifications() | ||
build_complete.send(sender=Build, build=self.build_env.build) | ||
|
||
self.build_env.update_build(state=BUILD_STATE_FINISHED) | ||
|
||
@staticmethod | ||
def get_project(project_pk): | ||
"""Get project from API""" | ||
project_data = api_v2.project(project_pk).get() | ||
project = APIProject(**project_data) | ||
return project | ||
return APIProject(**project_data) | ||
|
||
@staticmethod | ||
def get_version(project, version_pk): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicks because apparently this is very commonly seen copy:
Others:
"There was a problem with Read the Docs while building your documentation"
"We encountered an error with Read the Docs while building your documentation"