Skip to content
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

Improve message display in case of error on "export to csv" #93

Open
alfredchavez opened this issue Jul 9, 2021 · 0 comments
Open

Improve message display in case of error on "export to csv" #93

alfredchavez opened this issue Jul 9, 2021 · 0 comments

Comments

@alfredchavez
Copy link

alfredchavez commented Jul 9, 2021

With the new change on error display when export to csv button is used, I could see that when a task was successful and contained an error, it will display to the user the whole error, like this:
Error: Unexpected result: {'error': 'error!', 'report_filename': 'poll-data-export-2021-07-08-222643.csv', 'start_timestamp': 1625783203.2447248, 'generation_time_s': 0.018067359924316406}
which is caused by the way we keep this results(as a string with "Unexpected results: " added):

if task_result.successful():
    if isinstance(task_result.result, dict) and not task_result.result.get('error'):
        self.last_export_result = task_result.result
    else:
        self.last_export_result = {'error': u'Unexpected result: {}'.format(repr(task_result.result))} # <-- 
else:
    self.last_export_result = {'error': six.text_type(task_result.result)}

I think that would be better to send to json to the frontend instead of the repr and process it in the frontend itself showing just the "error" part to the user and logging the rest to the browser console

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant