[gnote] Handle Glib exceptions in sync thread
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Handle Glib exceptions in sync thread
- Date: Mon, 9 Mar 2020 21:47:54 +0000 (UTC)
commit 2ba0f20742588728e042606bbb0cf737e2fc10e9
Author: Aurimas Černius <aurisc4 gmail com>
Date: Mon Mar 9 23:46:27 2020 +0200
Handle Glib exceptions in sync thread
src/synchronization/syncmanager.cpp | 36 +++++++++++++++++++++++-------------
src/synchronization/syncmanager.hpp | 1 +
2 files changed, 24 insertions(+), 13 deletions(-)
---
diff --git a/src/synchronization/syncmanager.cpp b/src/synchronization/syncmanager.cpp
index 0af0eaa9..2c7c59f6 100644
--- a/src/synchronization/syncmanager.cpp
+++ b/src/synchronization/syncmanager.cpp
@@ -361,23 +361,33 @@ namespace sync {
set_state(IDLE);
}
+ catch(Glib::Exception & e) {
+ ERR_OUT(_("Synchronization failed with the following Glib exception: %s"), e.what().c_str());
+ abort_sync(server.get());
+ }
catch(std::exception & e) { // top-level try
ERR_OUT(_("Synchronization failed with the following exception: %s"), e.what());
- // TODO: Report graphically to user
- try {
- set_state(IDLE); // stop progress
- set_state(FAILED);
- set_state(IDLE); // required to allow user to sync again
- if(server != 0) {
- // TODO: All I really want to do here is cancel
- // the update lock timeout, but in most cases
- // this will delete lock files, too. Do better!
- server->cancel_sync_transaction();
- }
+ abort_sync(server.get());
+ }
+ }
+
+
+ void SyncManager::abort_sync(SyncServer *server)
+ {
+ // TODO: Report graphically to user
+ try {
+ set_state(IDLE); // stop progress
+ set_state(FAILED);
+ set_state(IDLE); // required to allow user to sync again
+ if(server != 0) {
+ // TODO: All I really want to do here is cancel
+ // the update lock timeout, but in most cases
+ // this will delete lock files, too. Do better!
+ server->cancel_sync_transaction();
}
- catch(...)
- {}
}
+ catch(...)
+ {}
}
diff --git a/src/synchronization/syncmanager.hpp b/src/synchronization/syncmanager.hpp
index 5175f7af..1cf91494 100644
--- a/src/synchronization/syncmanager.hpp
+++ b/src/synchronization/syncmanager.hpp
@@ -85,6 +85,7 @@ namespace sync {
NoteBase::Ptr find_note_by_uuid(const Glib::ustring & uuid);
NoteManagerBase & note_mgr();
void get_synchronized_xml_bits(const Glib::ustring & noteXml, Glib::ustring & title, Glib::ustring &
tags, Glib::ustring & content);
+ void abort_sync(SyncServer *server);
SyncUtils m_utils;
IGnote & m_gnote;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]