Refactors to spc timeouts and password error handling

This commit is contained in:
Mitchell 2019-06-12 16:51:29 -07:00
parent f90c19d0f4
commit e51ee55f07
5 changed files with 11 additions and 7 deletions

View file

@ -5,6 +5,7 @@ import (
"fmt"
"io/ioutil"
"os"
"strings"
"github.com/mitchellh/go-homedir"
"github.com/spf13/viper"
@ -69,7 +70,7 @@ func (mgr *ConfigManager) OpenConfig() (output string, v *viper.Viper, err error
return output, nil, err
}
if err = mgr.v.ReadConfig(bytes.NewBuffer(contents)); err != nil && err.Error() == "While parsing config: (1, 1): unexpected token" {
if err = mgr.v.ReadConfig(bytes.NewBuffer(contents)); err != nil && strings.HasPrefix(err.Error(), "While parsing config") {
return output, nil, fmt.Errorf("incorrect master password")
} else if err != nil {
return output, nil, err