Fix T56372: Properly show error messages when submission fails

This also introduces a word-wrapping function that takes variable character
widths into account.
This commit is contained in:
2018-08-14 15:05:37 +02:00
parent 9ed933760c
commit 7b88d7704c
4 changed files with 100 additions and 6 deletions

View File

@@ -348,7 +348,11 @@ class BENCHMARK_PT_main(Panel):
sub = col.row()
sub.enabled = not G.results_submitted
sub.scale_y = 2.25
sub.operator("benchmark.share", text="SHARE ONLINE")
if G.submission_exception:
text = "Retry Submission"
else:
text = "SHARE ONLINE"
sub.operator("benchmark.share", text=text)
sub = col.row()
subsub = sub.split()
@@ -631,10 +635,20 @@ class BENCHMARK_OT_share(bpy.types.Operator):
make_buttons_default()
print('Submitting benchmark')
G.submission_exception = None
try:
submission.submit_benchmark(G.result_dict)
except submission.CommunicationError as cex:
logger.ERROR(f'Error {cex.status_code} submitting benchmark: {cex.message}')
if cex.json:
logger.ERROR(f'Response JSON: {cex.json}')
else:
logger.ERROR(f'Response body: {cex.body}')
G.submission_exception = cex
return {'CANCELLED'}
except Exception as ex:
self.report({'ERROR'}, f'Error submitting results:\n{str(ex)[:100]}')
logger.ERROR(f'error submitting benchmark: {ex}')
G.submission_exception = ex
return {'CANCELLED'}
print('Submission done')
make_buttons_green()