Skip to content
Snippets Groups Projects
Commit 8a24774a authored by inso's avatar inso
Browse files

Added errors catching when posting important documents

parent 8d6dae1c
Branches
Tags
No related merge requests found
......@@ -57,7 +57,7 @@ class Community(object):
'''
self.currency = currency
self.peers = [p for p in peers if p.currency == currency]
self.cache = Cache(self)
self._cache = Cache(self)
# After initializing the community from latest peers,
# we refresh its peers tree
......@@ -72,7 +72,7 @@ class Community(object):
logging.debug("{0} peers found".format(len(self.peers)))
try:
self.cache.refresh()
self._cache.refresh()
except NoPeerAvailable:
pass
......@@ -164,9 +164,12 @@ class Community(object):
members.append(m['pubkey'])
return members
def refresh_cache(self):
self._cache.refresh()
def request(self, request, req_args={}, get_args={}, cached=True):
if cached:
return self.cache.request(request, req_args, get_args)
return self._cache.request(request, req_args, get_args)
else:
for peer in self.peers.copy():
e = next(e for e in peer.endpoints if type(e) is BMAEndpoint)
......
......@@ -54,6 +54,10 @@ class CertificationDialog(QDialog, Ui_CertificationDialog):
QMessageBox.critical(self, "Certification",
"Couldn't connect to network : {0}".format(e),
QMessageBox.Ok)
except Exception as e:
QMessageBox.critical(self, "Error",
"{0}".format(e),
QMessageBox.Ok)
self.accepted.emit()
self.close()
......
......@@ -115,6 +115,10 @@ class CommunityTabWidget(QWidget, Ui_CommunityTabWidget):
QMessageBox.critical(self, "Network error",
"Couldn't connect to network : {0}".format(e),
QMessageBox.Ok)
except Exception as e:
QMessageBox.critical(self, "Error",
"{0}".format(e),
QMessageBox.Ok)
def send_membership_leaving(self):
password = self.password_asker.ask()
......@@ -132,3 +136,8 @@ class CommunityTabWidget(QWidget, Ui_CommunityTabWidget):
QMessageBox.critical(self, "Network error",
"Couldn't connect to network : {0}".format(e),
QMessageBox.Ok)
except Exception as e:
QMessageBox.critical(self, "Error",
"{0}".format(e),
QMessageBox.Ok)
......@@ -37,6 +37,7 @@ class BlockchainWatcher(QObject):
blockid = self.community.current_blockid()
block_number = blockid['number']
if self.last_block != block_number:
self.community.refresh_cache()
for w in self.account.wallets:
w.refresh_cache(self.community)
......
......@@ -78,6 +78,10 @@ class TransferMoneyDialog(QDialog, Ui_TransferMoneyDialog):
QMessageBox.critical(self, "Money transfer",
"Couldn't connect to network : {0}".format(e),
QMessageBox.Ok)
except Exception as e:
QMessageBox.critical(self, "Error",
"{0}".format(e),
QMessageBox.Ok)
self.accepted.emit()
self.close()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment