~kf5jwc/garretts-plugin-google

69b80529b8014251aa2bbe6ce8182285f6f43aee — Kyle Jones 1 year, 5 months ago db93346
I should return the return from the original function.
1 files changed, 11 insertions(+), 7 deletions(-)

M text_synthesizer_plugin_google/exception_handler.py
M text_synthesizer_plugin_google/exception_handler.py => text_synthesizer_plugin_google/exception_handler.py +11 -7
@@ 1,18 1,22 @@
from google.auth.exceptions import DefaultCredentialsError
from text_synthesizer import PluginFileMissing, PluginError
from text_synthesizer import PluginFileMissing

from .plugin_files import credentials_file


FILE_PROMPT = "Please select your credentials file."
INVALID_CREDS_MSG = """
Valid credentials for Google services were not found!\n\nYou can find out how to \
acquire this file from \
https://developers.google.com/accounts/docs/application-default-credentials.
"""


def exception_catcher(fn):
    def func(*args, **kwargs):
        try:
            fn(*args, **kwargs)
            return fn(*args, **kwargs)
        except DefaultCredentialsError:
            raise PluginFileMissing(
                credentials_file,
                "Valid credentials for Google services were not found!\n\nYou can find out how to acquire this file from https://developers.google.com/accounts/docs/application-default-credentials.",
                "Please select your credentials file.",
            )
            raise PluginFileMissing(credentials_file, INVALID_CREDS_MSG, FILE_PROMPT)

    return func