refactor: unify error handling

This commit is contained in:
2025-09-03 21:09:42 +02:00
parent 6db6127522
commit 863171f66b
6 changed files with 54 additions and 40 deletions

View File

@@ -2,7 +2,6 @@ package config
import (
"fmt"
"os"
)
const DefaultBasicAuthUsername string = "ablage"
@@ -14,22 +13,22 @@ const VersionString string = "1.1"
var randomBasicAuthPassword string = generateRandomPassword()
func Init() {
func Init() error {
err := gatherDefaultPaths()
if err != nil {
panic(err)
return err
}
parseFlags()
if GetReadonlyMode() && GetSinkholeMode() {
fmt.Println("Error: Cannot enable both readonly and sinkhole modes at the same time.")
os.Exit(1)
return fmt.Errorf("Cannot enable both readonly and sinkhole modes at the same time.")
}
err = loadOrGenerateTLSCertificate()
if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
return err
}
return nil
}