Add error_message function

This commit is contained in:
gardouille 2020-12-02 15:58:35 +01:00
parent 8679335f19
commit 14c06c8b87
Signed by: gardouille
GPG Key ID: E759BAA22501AF32

18
qb
View File

@ -69,6 +69,17 @@ debug_message() { # {{{
return 0
}
# }}}
error_message() { # {{{
local_error_message="${1}"
local_error_code="${2}"
## Print message if DEBUG is enable (=0)
[ "${DEBUG}" -eq "0" ] && printf '%b\n' "ERROR ${PROGNAME}: ${RED}${local_error_message}${RESET}"
exit "${local_error_code:=66}"
}
# }}}
is_proc_running() { # {{{
local_proc_pattern="${1}"
@ -212,12 +223,9 @@ main() { # {{{
define_vars
## Try to get a working qutebrowser binary
### Or exit with error
### Or exit with error message and code 1
get_qutebrowser_bin \
|| debug_message "main \
Can't find a working qutebrowser binary." \
|| exit 2
|| error_message "Can't find a working qutebrowser binary." "1"
## If nothing related to Qutebrowser is currently running
### Try to start qutebrowser