Skip to content

Commit a9cf3ba

Browse files
committed
fix: gracefully handle missing profile config
1 parent e02f89e commit a9cf3ba

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

internal/pkg/profile/types.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package profile
22

33
import (
4+
"errors"
45
"path"
56

67
"github.com/spf13/viper"
@@ -34,7 +35,9 @@ func (p *Profile) Config() *Config {
3435
v := viper.New()
3536
v.SetConfigFile(path.Join(p.Directory, "config.json"))
3637

37-
if err := v.ReadInConfig(); err != nil {
38+
err := v.ReadInConfig()
39+
if err != nil && !errors.As(err, &viper.ConfigFileNotFoundError{}) {
40+
// For some reason viper doesnt implement Is() for ConfigFileNotFoundError
3841
panic(err) //todo
3942
}
4043

0 commit comments

Comments
 (0)