From a4420a06c13b77c64748caa5da81fef9efbe87fd Mon Sep 17 00:00:00 2001 From: Tony An Date: Thu, 27 Feb 2025 08:48:11 -0600 Subject: [PATCH] :wastebasket: Refactor error handling for configuration checks. Removed redundant error checks and streamlined logic for verifying service configuration. This simplifies the code and avoids duplicate error handling, improving maintainability. --- InfrastructureAgent/main.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/InfrastructureAgent/main.go b/InfrastructureAgent/main.go index 1ee2a0f8c9..63d54698de 100644 --- a/InfrastructureAgent/main.go +++ b/InfrastructureAgent/main.go @@ -84,11 +84,6 @@ func main() { os.Exit(2) } - if err != nil { - slog.Error(err.Error()) - os.Exit(2) - } - if len(os.Args) > 1 { cmd := os.Args[1] switch cmd { @@ -145,7 +140,7 @@ func main() { slog.Error(err.Error()) os.Exit(2) } - if err != nil || prg.config.SecretKey == "" || prg.config.OneUptimeURL == "" { + if prg.config.SecretKey == "" || prg.config.OneUptimeURL == "" { slog.Error("Service configuration not found or is incomplete. Please run 'oneuptime-infrastructure-agent configure' to configure the service.") os.Exit(2) } @@ -167,7 +162,7 @@ func main() { slog.Error(err.Error()) os.Exit(2) } - if err != nil || prg.config.SecretKey == "" || prg.config.OneUptimeURL == "" { + if prg.config.SecretKey == "" || prg.config.OneUptimeURL == "" { slog.Error("Service configuration not found or is incomplete. Please run 'oneuptime-infrastructure-agent configure' to configure the service.") os.Exit(2) }