@@ -80,21 +80,21 @@ func (c *ConfigHandler) getConfig() (Config, error) {
8080 // contain sensitive data from the config file or data that is being read in
8181 err := c .mainViper .MergeInConfig ()
8282 if err != nil {
83- return Config {}, fmt .Errorf ("could not read the main configuration file" )
83+ return Config {}, fmt .Errorf ("could not read the main configuration file: %w" , err )
8484 }
8585 // read secret config
8686 err = c .secretViper .ReadInConfig ()
8787 if err != nil {
8888 switch err .(type ) {
8989 default :
90- return Config {}, fmt .Errorf ("reading in the secret config failed" )
90+ return Config {}, fmt .Errorf ("reading in the secret config failed: %w" , err )
9191 case viper.ConfigFileNotFoundError :
9292 slog .Info ("could not find any secret config files - only the public file and environment variables will be used" )
9393 }
9494 }
9595 err = c .mainViper .MergeConfigMap (c .secretViper .AllSettings ())
9696 if err != nil {
97- return Config {}, fmt .Errorf ("could not merge the secret file config" )
97+ return Config {}, fmt .Errorf ("could not merge the secret file config: %w" , err )
9898 }
9999 // read environment variables
100100 envVarsFiltered := []string {}
@@ -109,7 +109,7 @@ func (c *ConfigHandler) getConfig() (Config, error) {
109109 envViper .SetConfigType ("env" )
110110 err = envViper .ReadConfig (envBuf )
111111 if err != nil {
112- return Config {}, fmt .Errorf ("could not read the environment variables into a config" )
112+ return Config {}, fmt .Errorf ("could not read the environment variables into a config: %w" , err )
113113 }
114114 envData := envViper .AllSettings ()
115115 prefix := strings .ToLower (c .envPrefix )
@@ -127,7 +127,7 @@ func (c *ConfigHandler) getConfig() (Config, error) {
127127 )
128128 err = c .mainViper .Unmarshal (& output , dh )
129129 if err != nil {
130- return Config {}, fmt .Errorf ("cannot unmarshal the combined config into a struct" )
130+ return Config {}, fmt .Errorf ("cannot unmarshal the combined config into a struct: %w" , err )
131131 }
132132 // NOTE: set PRODUCTION as the default running environment
133133 runningEnvironment := Production
0 commit comments