mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Display raw json content in case of exception
This commit is contained in:
parent
16245f53d9
commit
88b7d77610
2 changed files with 10 additions and 8 deletions
|
@ -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",
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue