diff --git a/misc/build.func b/misc/build.func index f401d566..1142ef9e 100644 --- a/misc/build.func +++ b/misc/build.func @@ -37,15 +37,14 @@ trap on_terminate TERM error_handler() { local exit_code="$1" local line_number="$2" - local command="$3" + local command="${3:-}" - # Exitcode 0 = kein Fehler → ignorieren if [[ "$exit_code" -eq 0 ]]; then return 0 fi printf "\e[?25h" - echo -e "\n${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}\n" + echo -e "\n${RD}[ERROR]${CL} in line ${RD}${line_number}${CL}: exit code ${RD}${exit_code}${CL}: while executing command ${YW}${command}${CL}\n" exit "$exit_code" } diff --git a/misc/create_lxc.sh b/misc/create_lxc.sh index b679ce13..36e4fcb9 100644 --- a/misc/create_lxc.sh +++ b/misc/create_lxc.sh @@ -33,15 +33,14 @@ trap on_terminate TERM error_handler() { local exit_code="$1" local line_number="$2" - local command="$3" + local command="${3:-}" - # Exitcode 0 = kein Fehler → ignorieren if [[ "$exit_code" -eq 0 ]]; then return 0 fi printf "\e[?25h" - echo -e "\n${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}\n" + echo -e "\n${RD}[ERROR]${CL} in line ${RD}${line_number}${CL}: exit code ${RD}${exit_code}${CL}: while executing command ${YW}${command}${CL}\n" exit "$exit_code" } diff --git a/misc/install.func b/misc/install.func index e3751c29..dd365527 100644 --- a/misc/install.func +++ b/misc/install.func @@ -32,19 +32,17 @@ catch_errors() { # This function handles errors error_handler() { source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/api.func) - printf "\e[?25h" - local exit_code="$?" - local line_number="$1" - local command="$2" - local error_message="${RD}[ERROR]${CL} in line ${RD}$line_number${CL}: exit code ${RD}$exit_code${CL}: while executing command ${YW}$command${CL}" - echo -e "\n$error_message" + local exit_code="$1" + local line_number="$2" + local command="${3:-}" - if [[ "$line_number" -eq 50 ]]; then - echo -e "The silent function has suppressed the error, run the script with verbose mode enabled, which will provide more detailed output.\n" - post_update_to_api "failed" "No error message, script ran in silent mode" - else - post_update_to_api "failed" "${command}" + if [[ "$exit_code" -eq 0 ]]; then + return 0 fi + + printf "\e[?25h" + echo -e "\n${RD}[ERROR]${CL} in line ${RD}${line_number}${CL}: exit code ${RD}${exit_code}${CL}: while executing command ${YW}${command}${CL}\n" + exit "$exit_code" } # This function sets up the Container OS by generating the locale, setting the timezone, and checking the network connection