comparison sat_pubsub/backend.py @ 494:468b7cd6c344 default tip

bookmark compat: handle mapped errors: This convert error on request (e.g. missing node) to appropriate stanza error.
author Goffi <goffi@goffi.org>
date Fri, 13 Dec 2024 12:23:47 +0100
parents 33222c54d2af
children
comparison
equal deleted inserted replaced
493:33222c54d2af 494:468b7cd6c344
1508 'service', 1508 'service',
1509 const.SERVICE_NAME) 1509 const.SERVICE_NAME)
1510 1510
1511 pubsubService = None 1511 pubsubService = None
1512 1512
1513 _errorMap = { 1513 error_map = {
1514 error.NodeNotFound: ('item-not-found', None, None), 1514 error.NodeNotFound: ('item-not-found', None, None),
1515 error.NodeExists: ('conflict', None, None), 1515 error.NodeExists: ('conflict', None, None),
1516 error.Forbidden: ('forbidden', None, None), 1516 error.Forbidden: ('forbidden', None, None),
1517 error.NotAuthorized: ('not-authorized', None, None), 1517 error.NotAuthorized: ('not-authorized', None, None),
1518 error.ItemNotFound: ('item-not-found', None, None), 1518 error.ItemNotFound: ('item-not-found', None, None),
1801 def _notifyPurge(self, data): 1801 def _notifyPurge(self, data):
1802 d = defer.ensureDeferred(self._aNotifyPurge(data)) 1802 d = defer.ensureDeferred(self._aNotifyPurge(data))
1803 d.addErrback(log.err) 1803 d.addErrback(log.err)
1804 1804
1805 def _mapErrors(self, failure): 1805 def _mapErrors(self, failure):
1806 e = failure.trap(*list(self._errorMap.keys())) 1806 e = failure.trap(*list(self.error_map.keys()))
1807 1807
1808 condition, pubsubCondition, feature = self._errorMap[e] 1808 condition, pubsubCondition, feature = self.error_map[e]
1809 msg = failure.value.msg 1809 msg = failure.value.msg
1810 1810
1811 if pubsubCondition: 1811 if pubsubCondition:
1812 exc = pubsub.PubSubError(condition, pubsubCondition, feature, msg) 1812 exc = pubsub.PubSubError(condition, pubsubCondition, feature, msg)
1813 else: 1813 else: