Better error messages

This commit is contained in:
natemaia 2019-09-30 19:45:54 -07:00
parent bb7dcfe5ba
commit d033ed7b23

View File

@ -5,7 +5,7 @@
# Some ideas and code reworked from other resources
# AIF, Cnichi, Calamares, Arch Wiki.. Credit where credit is due
VER=2.0.72
VER=2.0.73
# bulk default values {
@ -2228,22 +2228,19 @@ errshow()
local fatal=0 err=""
err="$(sed 's/[^[:print:]]//g; s/\[[0-9\;:]*\?m//g; s/==> //g; s/] ERROR:/]\nERROR:/g' "$ERR")"
[[ -z $err ]] && err="no error message was found"
(( $1 == 1 )) && { fatal=1; shift; }
if [[ $err ]]; then
local txt+="\nThe command exited abnormally:\n\n$1\n\nWith the following message:\n\n$err\n\n"
else
local txt+="\nThe command exited abnormally:\n\n$1\n\nWith no error message:\n\n"
fi
local txt="\nCommand: $1\n\n\n\nError: $err\n\n"
if (( fatal )); then
msg "Install Error" "${txt}Errors at this stage are fatal and the install cannot continue.\n"
msg "Install Error" "${txt}Errors at this stage are fatal, the install cannot continue.\n"
[[ -r $DBG && $TERM == 'linux' ]] && less "$DBG"
die 1
fi
msg "Install Error" "${txt}Errors at this stage are non-fatal and can be either fixed or ignored depending on the error.\n"
msg "Install Error" "${txt}Errors at this stage are non-fatal and may be fixed or ignored depending on the error.\n"
return 1
}