check if err is not nil first before checking error prefix

This commit is contained in:
Maidul Islam
2023-01-09 19:43:01 -05:00
parent 60a03cad98
commit 9aa8bfa1a2

View File

@ -32,9 +32,9 @@ var loginCmd = &cobra.Command{
PreRun: toggleDebug,
Run: func(cmd *cobra.Command, args []string) {
currentLoggedInUserDetails, err := util.GetCurrentLoggedInUserDetails()
if strings.Contains(err.Error(), "The specified item could not be found in the keyring") { // if the key can't be found allow them to override
if err != nil && strings.Contains(err.Error(), "The specified item could not be found in the keyring") { // if the key can't be found allow them to override
log.Debug(err)
} else {
} else if err != nil {
util.HandleError(err)
}