diff --git a/install/helpers/errors.sh b/install/helpers/errors.sh index 96b75f56..5a4c596d 100644 --- a/install/helpers/errors.sh +++ b/install/helpers/errors.sh @@ -74,6 +74,9 @@ restore_outputs() { # Error handler catch_errors() { + # Store exit code before any conditionals or assignments overwrite $?. + local exit_code=$? + # Prevent recursive error handling if [[ $ERROR_HANDLING == "true" ]]; then return @@ -81,9 +84,6 @@ catch_errors() { ERROR_HANDLING=true fi - # Store exit code immediately before it gets overwritten - local exit_code=$? - stop_log_output restore_outputs