Skip to content

Commit

Permalink
Merge branch 'develop_issue_#602' of https://github.com/kodaline/core
Browse files Browse the repository at this point in the history
…into kodaline-develop_issue_#602
  • Loading branch information
pieroit committed Dec 28, 2023
2 parents 5f62a40 + b70b80e commit 1b082b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion core/cat/mad_hatter/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from cat.mad_hatter.decorators import CatTool, CatHook, CatPluginOverride
from cat.utils import to_camel_case
from cat.log import log

from cat import utils

# Empty class to represent basic plugin Settings model
class PluginSettingsModel(BaseModel):
Expand Down Expand Up @@ -131,6 +131,8 @@ def load_settings(self):
except Exception as e:
log.error(f"Unable to load plugin {self._id} settings")
log.error(e)
log.warning(utils.plugin_specific_error_message(self.manifest["name"], self.manifest["plugin_url"]))
traceback.print_exc()
raise e
# settings.json does not exist # TODO: may be buggy or there is a better way via json_schema
#else:
Expand Down Expand Up @@ -166,6 +168,8 @@ def save_settings(self, settings: Dict):
json.dump(updated_settings, json_file, indent=4)
except Exception:
log.error(f"Unable to save plugin {self._id} settings")
log.warning(utils.plugin_specific_error_message(self.manifest["name"], self.manifest["plugin_url"]))
traceback.print_exc()
return {}

return updated_settings
Expand Down Expand Up @@ -226,6 +230,7 @@ def _load_decorated_functions(self):
plugin_overrides += getmembers(plugin_module, self._is_cat_plugin_override)
except Exception as e:
log.error(f"Error in {py_filename}: {str(e)}")
log.warning(utils.plugin_specific_error_message(self.manifest["name"], self.manifest["plugin_url"]))
traceback.print_exc()
raise Exception(f"Unable to load the plugin {self._id}")

Expand Down
3 changes: 3 additions & 0 deletions core/cat/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ def explicit_error_message(e):

return error_description

def plugin_specific_error_message(name, url):
return """To resolve any problem related to {} plugin,
contact the creator using github issue at the link {}""".format(name, url)

# This is our masterwork during tea time
class singleton:
Expand Down

0 comments on commit 1b082b0

Please sign in to comment.