mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
Update "error tracing" doc (#2216)
This commit is contained in:
parent
23b8523ee3
commit
054ee5bd09
|
@ -87,17 +87,20 @@ A construct to trace error in your scripts looks like this. Remember: Remove `se
|
|||
|
||||
```bash
|
||||
set -xeuEo pipefail
|
||||
trap '__log_err ${FUNCNAME[0]:-"?"} ${BASH_COMMAND:-"?"} ${LINENO:-"?"} ${?:-"?"}' ERR
|
||||
trap '__err "${BASH_SOURCE}" "${FUNCNAME[0]:-?}" "${BASH_COMMAND:-?}" "${LINENO:-?}" "${?:-?}"' ERR
|
||||
|
||||
SCRIPT='name_of_this_script.sh'
|
||||
|
||||
function __log_err
|
||||
function __err
|
||||
{
|
||||
printf "\n--- \e[1m\e[31mUNCHECKED ERROR\e[0m\n%s\n%s\n%s\n%s\n\n" \
|
||||
" - script = ${SCRIPT:-${0}}" \
|
||||
" - function = ${1} / ${2}" \
|
||||
" - line = ${3}" \
|
||||
" - exit code = ${4}" 1>&2
|
||||
local RED="\e[31m\e[1m"
|
||||
local RESET="\e[0m"
|
||||
local ERR_MSG="\n--- ${RED}UNCHECKED ERROR${RESET}"
|
||||
ERR_MSG+="\n - script = ${1}"
|
||||
ERR_MSG+="\n - function = ${2}"
|
||||
ERR_MSG+="\n - command = ${3}"
|
||||
ERR_MSG+="\n - line = ${4}"
|
||||
ERR_MSG+="\n - exit code = ${5}"
|
||||
|
||||
echo -e "${ERR_MSG}"
|
||||
|
||||
<CODE TO RUN AFTERWARDS>
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue