Skip to content

Commit f1e451b

Browse files
committed
Fix too broad exception
1 parent 524986b commit f1e451b

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

mattermost.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
from errbot.utils import split_string_after
1313
from mattermostdriver import Driver
1414
from mattermostdriver.exceptions import (
15-
InvalidOrMissingParameters, NotEnoughPermissions
16-
)
15+
InvalidOrMissingParameters, NotEnoughPermissions,
16+
ContentTooLarge, FeatureDisabled, NoAccessTokenProvided)
1717

1818
from src.mattermostPerson import MattermostPerson
1919
from src.mattermostRoom import MattermostRoom
@@ -366,7 +366,9 @@ def send_message(self, message):
366366
def send_card(self, card: Card):
367367
if isinstance(card.to, RoomOccupant):
368368
card.to = card.to.room
369+
369370
to_humanreadable, to_channel_id = self._prepare_message(card)
371+
370372
attachment = {}
371373
if card.summary:
372374
attachment['pretext'] = card.summary
@@ -396,7 +398,13 @@ def send_card(self, card: Card):
396398
# For this reason, we need to build our own url, since we need /hooks and not /api/v4
397399
# Todo: Reminder to check if this is still the case
398400
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+
):
400408
log.exception(
401409
"An exception occurred while trying to send a card to %s.[%s]" % (to_humanreadable, card)
402410
)

0 commit comments

Comments
 (0)