diff --git a/internal/config/config_handler.go b/internal/config/config_handler.go index 3a11fc78..09001e6e 100644 --- a/internal/config/config_handler.go +++ b/internal/config/config_handler.go @@ -80,21 +80,21 @@ func (c *ConfigHandler) getConfig() (Config, error) { // contain sensitive data from the config file or data that is being read in err := c.mainViper.MergeInConfig() if err != nil { - return Config{}, fmt.Errorf("could not read the main configuration file") + return Config{}, fmt.Errorf("could not read the main configuration file: %w", err) } // read secret config err = c.secretViper.ReadInConfig() if err != nil { switch err.(type) { default: - return Config{}, fmt.Errorf("reading in the secret config failed") + return Config{}, fmt.Errorf("reading in the secret config failed: %w", err) case viper.ConfigFileNotFoundError: slog.Info("could not find any secret config files - only the public file and environment variables will be used") } } err = c.mainViper.MergeConfigMap(c.secretViper.AllSettings()) if err != nil { - return Config{}, fmt.Errorf("could not merge the secret file config") + return Config{}, fmt.Errorf("could not merge the secret file config: %w", err) } // read environment variables envVarsFiltered := []string{} @@ -109,7 +109,7 @@ func (c *ConfigHandler) getConfig() (Config, error) { envViper.SetConfigType("env") err = envViper.ReadConfig(envBuf) if err != nil { - return Config{}, fmt.Errorf("could not read the environment variables into a config") + return Config{}, fmt.Errorf("could not read the environment variables into a config: %w", err) } envData := envViper.AllSettings() prefix := strings.ToLower(c.envPrefix) @@ -127,7 +127,7 @@ func (c *ConfigHandler) getConfig() (Config, error) { ) err = c.mainViper.Unmarshal(&output, dh) if err != nil { - return Config{}, fmt.Errorf("cannot unmarshal the combined config into a struct") + return Config{}, fmt.Errorf("cannot unmarshal the combined config into a struct: %w", err) } // NOTE: set PRODUCTION as the default running environment runningEnvironment := Production