Skip to content

Commit

Permalink
Fix too broad exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaelor committed Oct 9, 2017
1 parent 524986b commit f1e451b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions mattermost.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from errbot.utils import split_string_after
from mattermostdriver import Driver
from mattermostdriver.exceptions import (
InvalidOrMissingParameters, NotEnoughPermissions
)
InvalidOrMissingParameters, NotEnoughPermissions,
ContentTooLarge, FeatureDisabled, NoAccessTokenProvided)

from src.mattermostPerson import MattermostPerson
from src.mattermostRoom import MattermostRoom
Expand Down Expand Up @@ -366,7 +366,9 @@ def send_message(self, message):
def send_card(self, card: Card):
if isinstance(card.to, RoomOccupant):
card.to = card.to.room

to_humanreadable, to_channel_id = self._prepare_message(card)

attachment = {}
if card.summary:
attachment['pretext'] = card.summary
Expand Down Expand Up @@ -396,7 +398,13 @@ def send_card(self, card: Card):
# For this reason, we need to build our own url, since we need /hooks and not /api/v4
# Todo: Reminder to check if this is still the case
self.driver.client.make_request('post', '/' + self.cards_hook, options=data, basepath='/hooks')
except Exception:
except (
InvalidOrMissingParameters,
NotEnoughPermissions,
ContentTooLarge,
FeatureDisabled,
NoAccessTokenProvided
):
log.exception(
"An exception occurred while trying to send a card to %s.[%s]" % (to_humanreadable, card)
)
Expand Down

0 comments on commit f1e451b

Please sign in to comment.