Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions api/exitcodes.func
Original file line number Diff line number Diff line change
Expand Up @@ -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" ;;
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/error_handler.func
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion tests/exit-code-hints.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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')"
Expand Down
Loading