Skip to content

Commit

Permalink
Merge pull request #5 from hluk/more-messaging-exceptions
Browse files Browse the repository at this point in the history
Handle more fedora-messaging exceptions when publishing messages
  • Loading branch information
hluk authored Jul 11, 2022
2 parents a88689a + d57603a commit eb9ab27
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion resultsdb/messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

try:
from fedora_messaging.api import Message, publish
from fedora_messaging.exceptions import PublishReturned, ConnectionException
from fedora_messaging.exceptions import PublishReturned, PublishTimeout, PublishForbidden, ConnectionException
except ImportError:
if app.config.get('MESSAGE_BUS_PUBLISH_TASKOTRON') or app.config.get('MESSAGE_BUS_PLUGIN') == 'fedmsg':
log.error('fedora-messaging must be installed if "MESSAGE_BUS_PUBLISH_TASKOTRON" is '
Expand Down Expand Up @@ -113,6 +113,10 @@ def publish_taskotron_message(result, include_job_url=False):
log.debug("Message published")
except PublishReturned as e:
log.error('Fedora Messaging broker rejected message {}: {}'.format(msg.id, e))
except PublishTimeout:
log.error('Timeout publishing message {}'.format(msg.id))
except PublishForbidden as e:
log.error('Permission error publishing message {}: {}'.format(msg.id, e))
except ConnectionException as e:
log.error('Error sending message {}: {}'.format(msg.id, e.reason))

Expand Down Expand Up @@ -165,6 +169,10 @@ def publish(self, message):
log.debug("Message published")
except PublishReturned as e:
log.error('Fedora Messaging broker rejected message {}: {}'.format(msg.id, e))
except PublishTimeout:
log.error('Timeout publishing message {}'.format(msg.id))
except PublishForbidden as e:
log.error('Permission error publishing message {}: {}'.format(msg.id, e))
except ConnectionException as e:
log.error('Error sending message {}: {}'.format(msg.id, e.reason))

Expand Down

0 comments on commit eb9ab27

Please sign in to comment.