Skip to content

Commit 4585f3a

Browse files
committed
[update] : Added error message
1 parent 2e18220 commit 4585f3a

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

build.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# The main script that runs the build
1212
#
1313

14-
set -eu
14+
set -Eeu
1515

1616
# Internal config
1717
# Do not change these values.
@@ -27,6 +27,7 @@ pkglist_args=()
2727
makepkg_script_args=()
2828
modules=()
2929
DEFAULT_ARGUMENT=""
30+
ARGUMENT=("${@}")
3031
alteriso_version="3.1"
3132

3233
# Load config file
@@ -362,11 +363,18 @@ prepare_env() {
362363
[[ "${normwork}" = false ]] && echo && _run_cleansh
363364
exit "${status}"
364365
}
365-
trap '_trap_remove_work' 1 2 3 15
366+
trap '_trap_remove_work' HUP INT QUIT TERM
366367

367368
return 0
368369
}
369370

371+
# Error message
372+
error_exit_trap(){
373+
local _exit="${?}" _line="${1}" && shift 1
374+
msg_error "An exception error occurred in the function"
375+
msg_error "Exit Code: ${_exit}\nLine: ${_line}\nArgument: ${ARGUMENT[*]}"
376+
exit "${_exit}"
377+
}
370378

371379
# Show settings.
372380
show_settings() {
@@ -385,8 +393,9 @@ show_settings() {
385393
echo -e "\nPress Enter to continue or Ctrl + C to cancel."
386394
read -r
387395
fi
388-
trap 1 2 3 15
389-
trap 'umount_trap' 1 2 3 15
396+
trap HUP INT QUIT TERM
397+
trap 'umount_trap' HUP INT QUIT TERM
398+
trap 'error_exit_trap $LINENO' ERR
390399

391400
return 0
392401
}
@@ -478,8 +487,6 @@ prepare_build() {
478487
msg_warn "Re-run sudo ${0} ${ARGUMENT[*]} --nodepend --nolog --nocolor 2>&1 | tee ${logging}"
479488
sudo "${0}" "${ARGUMENT[@]}" --nolog --nocolor --nodepend 2>&1 | tee "${logging}"
480489
exit "${?}"
481-
else
482-
unset ARGUMENT
483490
fi
484491

485492
# Set argument of pkglist.sh

0 commit comments

Comments
 (0)