-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Handle raising exceptions from PublicTask #4078
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 all commits
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 |
---|---|---|
|
@@ -29,10 +29,12 @@ def get_status_data(task_name, state, data, error=None): | |
'data': data, | ||
'started': state in STARTED_STATES, | ||
'finished': state in FINISHED_STATES, | ||
'success': state in SUCCESS_STATES, | ||
# When an exception is raised inside the task, we keep this as SUCCESS | ||
# and add the exception messsage into the 'error' key | ||
'success': state in SUCCESS_STATES and error is None, | ||
} | ||
if error is not None and isinstance(error, Exception): | ||
data['error'] = error.message | ||
if error is not None: | ||
data['error'] = error | ||
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. Similarly, we should probably we defensive here about what error is. Are we sure it will always be a string type, or should we be actively turning it into a string here, also? 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. It should be always a string since that |
||
return data | ||
|
||
|
||
|
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.
Is there a reason we are passing the string here instead of the actual Exception object? It seems like this limits what we can do with it later on
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.
Yes. I had different problems when trying to serialize an Exception object. In fact, this serialization problem was one of the things that originated this issue.