fastly / fastly-py

A Fastly API client for Python
https://pypi.org/project/fastly/
MIT License
77 stars 60 forks source link

Provide a base class for Error/Exception classes #21

Closed linusthe3rd closed 6 years ago

linusthe3rd commented 9 years ago

When writing a try-except block to catch this library's exceptions, one has to add extra lines to catch everything:

    try:
        # make calls to fastly   
    except (
        fastly.errors.AuthenticationError,
        fastly.errors.InternalServerError,
        fastly.errors.BadRequestError,
        fastly.errors.NotFoundError
    ) as e:
        # handle exception

It would be nice if the error classes shared the same base class so that consumers only had to catch a single exception:

    try:
        # make calls to fastly   
    except fastly.errors.FastlyError as e:
        # handle exception
lisac commented 8 years ago

That shared base class is a nice idea, @strife25. I tried it in PR #28, will monitor it for feedback.

BryanTheScott commented 6 years ago

It would be great to see that merged back in to master. I had the same reaction as linus, and the PR by @lisac seems painless enough to incorporate.

psbanka commented 6 years ago

Fixed with v0.2.3