diff --git a/api/exitcodes.func b/api/exitcodes.func index 266ab80..973cda2 100644 --- a/api/exitcodes.func +++ b/api/exitcodes.func @@ -215,8 +215,8 @@ explain_exit_code() { 253) echo "App: Data migration required — update aborted" ;; 254) echo "App: User declined prompt or input timed out" ;; - # --- DPKG --- - 255) echo "DPKG: Fatal internal error" ;; + # --- 255 --- + 255) echo "Fatal error (exit 255 from qm, pct, ssh or dpkg)" ;; # --- Default --- *) echo "Unknown error" ;; @@ -240,6 +240,8 @@ categorize_error() { if [[ -z "$command" ]] && declare -f _tm_find_errinfo >/dev/null 2>&1 && errinfo=$(_tm_find_errinfo); then command=$(sed -n 's/^COMMAND=//p' "$errinfo" | head -n1) fi + command="${command#\$STD }" + command="${command#\$\{STD:-\} }" tool="${command%% *}" tool="${tool##*/}" case "$tool" in diff --git a/core/error_handler.func b/core/error_handler.func index 2430e6a..1aa0712 100644 --- a/core/error_handler.func +++ b/core/error_handler.func @@ -195,7 +195,7 @@ _eh_explanation() { if [[ -n "$tools" ]] && ! _eh_command_is "$command" "$tools"; then explanation="${word:+${word} exited with status ${exit_code}}" explanation="${explanation:-Exit status ${exit_code}}" - elif [[ "$exit_code" =~ ^[123]$ && -n "$word" ]]; then + elif [[ "$exit_code" =~ ^([123]|255)$ && -n "$word" ]]; then explanation="${word} exited with status ${exit_code}" fi fi diff --git a/tests/exit-code-hints.sh b/tests/exit-code-hints.sh index d97e6ef..948cab3 100644 --- a/tests/exit-code-hints.sh +++ b/tests/exit-code-hints.sh @@ -57,11 +57,13 @@ expect "pct exec 255 is not a DPKG error" "exit_code=255 | pct exited with statu expect "step and function join the header" "exit_code=7 | Exit status 7 | step: Setting up Grafana Repository | in setup_deb822_repo | at line 24: return 7" "$(CS_STEP='Setting up Grafana Repository' FAILED_FUNCTION=setup_deb822_repo FAILED_COMMAND='return 7' FAILED_LINE=24 build_error_string 7)" expect "a finished step is named as such" "exit_code=64 | Missing or invalid input (a required setting was not given) | step: after Updated Container OS" "$(CS_STEP_DONE='Updated Container OS' FAILED_COMMAND= build_error_string 64)" expect "apt 100 keeps the APT text" APT "$(FAILED_COMMAND='apt install -y grafana' FAILED_LINE=31 build_error_string 100 | cut -d'|' -f2 | cut -d: -f1 | tr -d ' ')" -expect "without a command the table stands" "exit_code=255 | DPKG: Fatal internal error" "$(FAILED_COMMAND= build_error_string 255)" +expect "without a command the table stands" "exit_code=255 | Fatal error (exit 255 from qm, pct, ssh or dpkg)" "$(FAILED_COMMAND= build_error_string 255)" # The category follows the tool where the code is shared. expect "systemctl is a service failure" service "$(categorize_error 5 'systemctl start portainer')" expect "pct exec is a Proxmox failure" proxmox "$(categorize_error 255 'pct exec 100 -- ip a')" +expect "\$STD qm start in a VM script is one too" proxmox "$(categorize_error 255 '$STD qm start $VMID')" +expect "and \${STD:-} pct start" proxmox "$(categorize_error 255 '${STD:-} pct start 105')" expect "a kill stays a resource failure whatever ran" resource "$(categorize_error 137 'pct exec 100 -- cargo build')" expect "apt keeps its category" dependency "$(categorize_error 100 'apt install -y grafana')" expect "an abort stays an abort" user_aborted "$(categorize_error 130 'systemctl start x')"