diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 076096eef..7a8fa695a 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -930,7 +930,7 @@ def app_install(operation_logger, app, label=None, args=None, no_remove_on_failu permission_sync_to_user() - raise YunohostError(failure_message_with_debug_instructions, raw_msg=True) + raise YunohostError(failure_message_with_debug_instructions, raw_msg=True, log_ref=operation_logger.name) # Clean hooks and add new ones hook_remove(app_instance_name) diff --git a/src/yunohost/utils/error.py b/src/yunohost/utils/error.py index f2486473b..78077b42a 100644 --- a/src/yunohost/utils/error.py +++ b/src/yunohost/utils/error.py @@ -32,11 +32,23 @@ class YunohostError(MoulinetteError): are translated via m18n.n (namespace) instead of m18n.g (global?) """ - def __init__(self, key, raw_msg=False, *args, **kwargs): + def __init__(self, key, raw_msg=False, log_ref=None, *args, **kwargs): self.key = key # Saving the key is useful for unit testing self.kwargs = kwargs # Saving the key is useful for unit testing + self.log_ref = log_ref if raw_msg: msg = key else: msg = m18n.n(key, *args, **kwargs) + super(YunohostError, self).__init__(msg, raw_msg=True) + + def content(self): + + if not self.log_ref: + return super(YunohostError, self).content() + else: + return { + "error": self.strerror, + "log_ref": self.log_ref + }