comparison src/plugins/plugin_misc_account.py @ 751:1def5b7edf9f

core, bridge: better GenericException handling
author Goffi <goffi@goffi.org>
date Tue, 17 Dec 2013 00:56:39 +0100
parents fe05afc3f0df
children bfabeedbf32e
comparison
equal deleted inserted replaced
750:c8b9f675ac17 751:1def5b7edf9f
77 if (reason.value.exitCode == 0): 77 if (reason.value.exitCode == 0):
78 info(_('Prosody registration success')) 78 info(_('Prosody registration success'))
79 self.deferred.callback(None) 79 self.deferred.callback(None)
80 else: 80 else:
81 error(_(u"Can't register Prosody account (error code: %(code)d): %(message)s") % {'code': reason.value.exitCode, 'message': self.data}) 81 error(_(u"Can't register Prosody account (error code: %(code)d): %(message)s") % {'code': reason.value.exitCode, 'message': self.data})
82 self.deferred.errback(Failure(u"INTERNAL")) 82 self.deferred.errback(Failure(exceptions.InternalError))
83 83
84 84
85 class MiscAccount(object): 85 class MiscAccount(object):
86 """Account plugin: create a SàT + Prosody account, used by Libervia""" 86 """Account plugin: create a SàT + Prosody account, used by Libervia"""
87 #XXX: This plugin is a Q&D one used for the demo. Something more generic (and not 87 #XXX: This plugin is a Q&D one used for the demo. Something more generic (and not
116 """ 116 """
117 if not email or not password or not profile: 117 if not email or not password or not profile:
118 raise exceptions.DataError 118 raise exceptions.DataError
119 119
120 if profile.lower() in self.getConfig('reserved_list'): 120 if profile.lower() in self.getConfig('reserved_list'):
121 return defer.fail(Failure(u'CONFLICT')) 121 return defer.fail(Failure(exceptions.ConflictError))
122 122
123 d = self.host.memory.asyncCreateProfile(profile) 123 d = self.host.memory.asyncCreateProfile(profile)
124 d.addCallback(self._profileRegistered, email, password, profile) 124 d.addCallback(self._profileRegistered, email, password, profile)
125 return d 125 return d
126 126