Skip to content

Exception Catching  #1248

@the-c0d3r

Description

@the-c0d3r

Version: 3.3.11

Description: catching classes that do not inherit from BaseException is not allowed

Sample code

try:
    r = redis.Redis(...)
except redis.exceptions as error:
    print("Operation failed due to error: ", error)

This way of catching exceptions return an exception from python complaining the aforementioned exception message. I know that one can catch it as a broad Exception and check the erorr type, but that is a very broad exception. Is there any way to catch all the exceptions under redis.exceptions? I think this can be resolved if the exceptions in redis/exceptions.py are inheriting from BaseException class.

Please let me know your thoughts on this, how to catch all the redis exceptions. I can put up a PR if my solution is deemed to be correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions