diff --git a/helpers/helpers.v2.1.d/apt b/helpers/helpers.v2.1.d/apt index d8425ee58..4c78a2147 100644 --- a/helpers/helpers.v2.1.d/apt +++ b/helpers/helpers.v2.1.d/apt @@ -134,12 +134,12 @@ EOF # Fake an install of those dependencies to see the errors # The sed command here is, Print only from 'Reading state info' to the end. [[ -n "$problematic_dependencies" ]] && _ynh_apt_install $problematic_dependencies --dry-run 2>&1 | sed --quiet '/Reading state info/,$p' | grep -v "fix-broken\|Reading state info" >&2 - ynh_die "Unable to install dependencies" + ynh_die "Unable to install apt dependencies" } rm --recursive --force "$TMPDIR" # Remove the temp dir. # check if the package is actually installed - _ynh_apt_package_is_installed "${app_ynh_deps}" || ynh_die "Unable to install dependencies" + _ynh_apt_package_is_installed "${app_ynh_deps}" || ynh_die "Unable to install apt dependencies" # Specific tweak related to Postgresql # -> trigger postgresql regenconf if we may have just installed postgresql diff --git a/helpers/helpers.v2.1.d/logging b/helpers/helpers.v2.1.d/logging index 4649cf670..eb4ddbb59 100644 --- a/helpers/helpers.v2.1.d/logging +++ b/helpers/helpers.v2.1.d/logging @@ -4,7 +4,11 @@ # # usage: ynh_die "Some message" ynh_die() { - echo "$1" 1>&2 + if [[ -n "${1:-}" ]] + then + python3 -c 'import yaml, sys; print(yaml.dump({"error": sys.stdin.read()}))' <<< "${1:-}" >>"$YNH_STDRETURN" + echo "${1:-}" 1>&2 + fi exit 1 } diff --git a/src/hook.py b/src/hook.py index ee9f08e48..49c2f4cc3 100644 --- a/src/hook.py +++ b/src/hook.py @@ -538,6 +538,9 @@ def hook_exec_with_script_debug_if_failure(*args, **kwargs): failed = True if retcode != 0 else False if failed: error = error_message_if_script_failed + # check more specific error message added by ynh_die in $YNH_STDRETURN + if isinstance(retpayload, dict) and "error" in retpayload: + error += " : " + retpayload["error"].strip() logger.error(error_message_if_failed(error)) failure_message_with_debug_instructions = operation_logger.error(error) if Moulinette.interface.type != "api":