Skip to content

Commit

Permalink
fix: gracefully handle missing profile config
Browse files Browse the repository at this point in the history
  • Loading branch information
mworzala committed Sep 15, 2023
1 parent e02f89e commit a9cf3ba
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/pkg/profile/types.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package profile

import (
"errors"
"path"

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

if err := v.ReadInConfig(); err != nil {
err := v.ReadInConfig()
if err != nil && !errors.As(err, &viper.ConfigFileNotFoundError{}) {
// For some reason viper doesnt implement Is() for ConfigFileNotFoundError
panic(err) //todo
}

Expand Down

0 comments on commit a9cf3ba

Please sign in to comment.