diff --git a/locales/en.json b/locales/en.json index a6d95ada1..ca1d9c8a1 100644 --- a/locales/en.json +++ b/locales/en.json @@ -211,7 +211,7 @@ "good_practices_about_user_password": "You are now about to define a new user password. The password should be at least 8 characters - though it is good practice to use longer password (i.e. a passphrase) and/or to use various kind of characters (uppercase, lowercase, digits and special characters).", "hook_exec_failed": "Script execution failed: {path:s}", "hook_exec_not_terminated": "Script execution hasn\u2019t terminated: {path:s}", - "hook_json_return_error": "Failed to read return from hook {path:s}. Error: {msg:s}", + "hook_json_return_error": "Failed to read return from hook {path:s}. Error: {msg:s}. Raw content: {raw_content}", "hook_list_by_invalid": "Invalid property to list hook by", "hook_name_unknown": "Unknown hook name '{name:s}'", "installation_complete": "Installation complete", diff --git a/src/yunohost/hook.py b/src/yunohost/hook.py index 961caf606..c4605b6e8 100644 --- a/src/yunohost/hook.py +++ b/src/yunohost/hook.py @@ -395,15 +395,17 @@ def hook_exec(path, args=None, raise_on_error=False, no_trace=False, elif raise_on_error and returncode != 0: raise YunohostError('hook_exec_failed', path=path) + raw_content = None try: - - with open(stdreturn, 'r') as f: - if f.read() != '': - returnjson = read_json(stdreturn) - else: - returnjson = {} + with open(stdreturn, 'r') as f: + raw_content = f.read() + if raw_content != '': + returnjson = read_json(stdreturn) + else: + returnjson = {} except Exception as e: - raise YunohostError('hook_json_return_error', path=path, msg=str(e)) + raise YunohostError('hook_json_return_error', path=path, msg=str(e), + raw_content=raw_content) finally: stdreturndir = os.path.split(stdreturn)[0] os.remove(stdreturn)