changeset 190:33ac2d2ce5d7

core: new errback method which can be use as a generic way to show error as notes
author Goffi <goffi@goffi.org>
date Tue, 22 May 2018 19:25:23 +0200
parents a91abcd6d9a5
children fda3f22aa3ce
files cagou/core/cagou_main.py
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/cagou/core/cagou_main.py	Tue May 22 19:25:23 2018 +0200
+++ b/cagou/core/cagou_main.py	Tue May 22 19:25:23 2018 +0200
@@ -708,6 +708,9 @@
     def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE):
         log.info(u"Profile presence status set to {show}/{status}".format(show=show, status=status))
 
+    def errback(self, failure_, title=_('error'), message=_(u'error while processing: {msg}')):
+        self.addNote(title, message.format(msg=failure_), level=C.XMLUI_DATA_LVL_WARNING)
+
     def addNote(self, title, message, level=C.XMLUI_DATA_LVL_INFO):
         """add a note (message which disappear) to root widget's header"""
         self.app.root.addNote(title, message, level)