github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/git/errors.go (about) 1 package git 2 3 import ( 4 "fmt" 5 6 "github.com/keybase/client/go/libkb" 7 "golang.org/x/net/context" 8 ) 9 10 // For errors that expect, replace them with nice strings for the user. The GUI 11 // will show these directly. 12 func HumanizeGitErrors(ctx context.Context, g *libkb.GlobalContext, err error) error { 13 switch e := err.(type) { 14 case libkb.RepoAlreadyExistsError: 15 g.Log.CDebugf(ctx, "replacing error: %v", err) 16 return fmt.Errorf("A repo named %q already exists.", e.ExistingName) 17 case libkb.InvalidRepoNameError: 18 g.Log.CDebugf(ctx, "replacing error: %v", err) 19 return fmt.Errorf("%q isn't a valid repo name.", e.Name) 20 default: 21 return err 22 } 23 }