Skip to content

Commit

Permalink
add option to submit logs when download fails
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Nov 1, 2023
1 parent ac56189 commit ab56e42
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Mergin/projects_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,8 @@ def download_project(self, project):
dlg.exception_details(),
"Project download",
f"Failed to download project {project_name} due to an unhandled exception.",
dlg.log_file,
self.mc.username(),
)
return
if not dlg.is_complete:
Expand Down
3 changes: 3 additions & 0 deletions Mergin/sync_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def __init__(self, parent=None):
self.exception_tb = None
self.is_complete = False
self.job = None
self.log_file = None

self.timer = QTimer(self)
self.timer.setInterval(100)
Expand All @@ -72,6 +73,8 @@ def cancel_operation(self):
self.pull_cancel()

def reset_operation(self, success, close, exception=None):
if self.job.failure_log_file is not None:
self.log_file = self.job.failure_log_file
self.operation = None
self.mergin_client = None
self.target_dir = None
Expand Down
17 changes: 15 additions & 2 deletions Mergin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ def login_error_message(e):
QMessageBox.critical(None, "Login failed", msg, QMessageBox.Close)


def unhandled_exception_message(error_details, dialog_title, error_text):
def unhandled_exception_message(error_details, dialog_title, error_text, log_file=None, username=None):
msg = (
error_text + "<p>This should not happen, "
'<a href="https://github.com/MerginMaps/qgis-mergin-plugin/issues">'
Expand All @@ -910,7 +910,20 @@ def unhandled_exception_message(error_details, dialog_title, error_text):
box.setIcon(QMessageBox.Critical)
box.setWindowTitle(dialog_title)
box.setText(msg)
box.setDetailedText(error_details)
if log_file is None:
box.setDetailedText(error_details)
else:
error_details = (
"An error occured during project synchronisation. The log was saved to "
f"{log_file}. Click 'Send logs' to send a diagnostic log to the developers "
"to help them determine the exact cause of the problem.\n\n"
"The log does not contain any of your data, only file names. "
"It would be useful if you also send a mail to [email protected] "
"and briefly describe the problem to add more context to the diagnostic log."
)
box.setDetailedText(error_details)
btn = box.addButton("Send logs", QMessageBox.ActionRole)
btn.clicked.connect(lambda: submit_logs(username, log_file))
box.exec_()


Expand Down

0 comments on commit ab56e42

Please sign in to comment.