error-log

This commit is contained in:
CanbiZ
2025-09-16 08:58:01 +02:00
parent cde9ae6d4b
commit 5c750affa5
3 changed files with 13 additions and 7 deletions

View File

@@ -81,11 +81,13 @@ explain_exit_code() {
# === Error handler ============================================================
error_handler() {
local exit_code=$?
local exit_code=${1:-$?}
local line_number=${BASH_LINENO[0]:-unknown}
local command=${BASH_COMMAND:-unknown}
# Exitcode 0 = kein Fehler → ignorieren
# $STD im Kommando entfernen (nur kosmetisch)
command=${command//\$STD /}
if [[ "$exit_code" -eq 0 ]]; then
return 0
fi
@@ -107,6 +109,13 @@ error_handler() {
} >>"$DEBUG_LOGFILE"
fi
# Silent-Log
if [[ -n "${SILENT_LOGFILE:-}" && -s "$SILENT_LOGFILE" ]]; then
echo "--- Last 20 lines of silent log ($SILENT_LOGFILE) ---"
tail -n 20 "$SILENT_LOGFILE"
echo "---------------------------------------------------"
fi
exit "$exit_code"
}