caravelahc / pico-bot

Gerador de stickers de mensagens do Telegram
15 stars 5 forks source link

Capture specific exception types in `except` #40

Open JPTIZ opened 2 years ago

JPTIZ commented 2 years ago

Some exception handling code take the generic type Exception in except and, in a couple cases:

https://github.com/caravelahc/pico-bot/blob/f4c6255ace0d49beb98b94e528f090f04fbd6b6b/picobot/handlers.py#L175 https://github.com/caravelahc/pico-bot/blob/f4c6255ace0d49beb98b94e528f090f04fbd6b6b/picobot/handlers.py#L220 https://github.com/caravelahc/pico-bot/blob/f4c6255ace0d49beb98b94e528f090f04fbd6b6b/picobot/handlers.py#L272

And, after #34 is merged:

https://github.com/caravelahc/pico-bot/blob/033e461622f419a3ab3edb3c100f3e1080ba2470/picobot/handlers.py#L342

So instead of doing:

except Exception as exc:
    if isinstance(exc, SpecificType):

We should slightly rework the code to get exceptions as:

except SpecificType as error: