@@ 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