refactor: extract logFatal helper for config error handling

Replace 14 repeated fmt.Fprintln(os.Stderr, "FATAL:", ...)/os.Exit(1)
patterns with a single logFatal function. This reduces duplication
and makes all fatal config paths testable via SetLogFatal.

Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
Deluan
2026-03-28 13:23:03 -04:00
parent 2b041c02ad
commit 049fc78177
3 changed files with 81 additions and 39 deletions
+4 -4
View File
@@ -14,8 +14,8 @@ var NormalizeSearchBackend = normalizeSearchBackend
var ToPascalCase = toPascalCase
func SetFatalFunc(f func(string)) func() {
old := fatalFunc
fatalFunc = f
return func() { fatalFunc = old }
func SetLogFatal(f func(...any)) func() {
old := logFatal
logFatal = f
return func() { logFatal = old }
}