Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved exception handling required #4

Open
e-dreyer opened this issue Jul 25, 2023 · 1 comment
Open

Improved exception handling required #4

e-dreyer opened this issue Jul 25, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@e-dreyer
Copy link
Owner

Problem

Currently MastoBot implements a wrapper and decorator function which allows for the handling of exceptions in most functions making API calls through Mastodon.py. This however is not the best solution. Exceptions are still able to slip through and there is actually no handling of exceptions and they are rather logged.

It should be investigated how a queue system for API calls can be created and operations then postponed until a connection error or rate limiting possibly sort itself out.

Related issues

Current solution

def handleMastodonExceptions(func) -> Callable:
    def wrapper(self, *args, **kwargs):
        try:
            result = func(self, *args, **kwargs)
            return result
        except MastodonServerError as e:
            logging.critical(f"MastodonServerError: {e}")
        except MastodonIllegalArgumentError as e:
            logging.critical(f"MastodonIllegalArgumentError: {e}")
        except MastodonFileNotFoundError as e:
            logging.critical(f"MastodonFileNotFoundError: {e}")
        except MastodonNetworkError as e:
            logging.critical(f"MastodonNetworkError: {e}")
        except MastodonAPIError as e:
            logging.critical(f"MastodonAPIError: {e}")
        except MastodonMalformedEventError as e:
            logging.critical(f"MastodonMalformedEventError: {e}")
        except MastodonRatelimitError as e:
            logging.critical(f"MastodonRatelimitError: {e}")
        except MastodonVersionError as e:
            logging.critical(f"MastodonVersionError: {e}")
        except Exception as e:
            logging.critical(f"Error in function {func.__name__}")
            logging.critical(e)
            raise e
    return wrapper
@e-dreyer e-dreyer added the enhancement New feature or request label Jul 25, 2023
@e-dreyer e-dreyer self-assigned this Jul 25, 2023
@e-dreyer
Copy link
Owner Author

As proposed in #6, a data storage system would help a lot with systems like this. Because pending notifications should persist through a restart or crash. How to implement such a storage system is the question.

Even by implementing some caching system, would require a persistent store. Doing so, would complicate the Docker setup. Ideally we want the user to be able to completely define their own Docker setup and not require extra containers or images such as Redis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

1 participant