Skip to content

Commit

Permalink
better errors for gui config migration (keybase#18545)
Browse files Browse the repository at this point in the history
* better errors for gui config migration
  • Loading branch information
heronhaye authored Jul 24, 2019
1 parent 526d5f0 commit 7967214
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion go/libkb/globals.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,9 @@ func migrateGUIConfig(serviceConfig ConfigReader, guiConfig *JSONFile) error {
p = "ui.importContacts"
syncSettings, err := serviceConfig.GetInterfaceAtPath(p)
if err != nil {
errs = append(errs, err)
if !isJSONNoSuchKeyError(err) {
errs = append(errs, err)
}
} else {
syncSettings, ok := syncSettings.(map[string]interface{})
if !ok {
Expand Down
6 changes: 6 additions & 0 deletions go/libkb/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"io"
"os"
"runtime"
"strings"
"sync"

jsonw "github.com/keybase/go-jsonw"
Expand Down Expand Up @@ -494,3 +495,8 @@ func (f *JSONFile) SetNullAtPath(p string) (err error) {
}
return err
}

func isJSONNoSuchKeyError(err error) bool {
_, isJSONError := err.(*jsonw.Error)
return err != nil && isJSONError && strings.Contains(err.Error(), "no such key")
}

0 comments on commit 7967214

Please sign in to comment.