|
12 | 12 | from errbot.utils import split_string_after |
13 | 13 | from mattermostdriver import Driver |
14 | 14 | from mattermostdriver.exceptions import ( |
15 | | - InvalidOrMissingParameters, NotEnoughPermissions |
16 | | -) |
| 15 | + InvalidOrMissingParameters, NotEnoughPermissions, |
| 16 | + ContentTooLarge, FeatureDisabled, NoAccessTokenProvided) |
17 | 17 |
|
18 | 18 | from src.mattermostPerson import MattermostPerson |
19 | 19 | from src.mattermostRoom import MattermostRoom |
@@ -366,7 +366,9 @@ def send_message(self, message): |
366 | 366 | def send_card(self, card: Card): |
367 | 367 | if isinstance(card.to, RoomOccupant): |
368 | 368 | card.to = card.to.room |
| 369 | + |
369 | 370 | to_humanreadable, to_channel_id = self._prepare_message(card) |
| 371 | + |
370 | 372 | attachment = {} |
371 | 373 | if card.summary: |
372 | 374 | attachment['pretext'] = card.summary |
@@ -396,7 +398,13 @@ def send_card(self, card: Card): |
396 | 398 | # For this reason, we need to build our own url, since we need /hooks and not /api/v4 |
397 | 399 | # Todo: Reminder to check if this is still the case |
398 | 400 | self.driver.client.make_request('post', '/' + self.cards_hook, options=data, basepath='/hooks') |
399 | | - except Exception: |
| 401 | + except ( |
| 402 | + InvalidOrMissingParameters, |
| 403 | + NotEnoughPermissions, |
| 404 | + ContentTooLarge, |
| 405 | + FeatureDisabled, |
| 406 | + NoAccessTokenProvided |
| 407 | + ): |
400 | 408 | log.exception( |
401 | 409 | "An exception occurred while trying to send a card to %s.[%s]" % (to_humanreadable, card) |
402 | 410 | ) |
|
0 commit comments