@cryptotaxi247 / kubo / commits / a0af9f5e8

If ErrNoRepo is not an error value anymore, then make it an error type

Tommi Virtanen committed Apr 28, 2015 at 16:18 UTC a0af9f5e8d19d1ed469ff1ab025fd1923075cd16
1 file changed +11 -2
repo/fsrepo/fsrepo.go
+11 -2
@@ -40,11 +40,20 @@ Please run the ipfs migration tool before continuing.
40 ` + migrationInstructions
41
42 var (
43 - ErrNoRepo = func (path string) error { return fmt.Errorf("no ipfs repo found in '%s'. please run: ipfs init ", path) }
43 ErrNoVersion = errors.New("no version file found, please run 0-to-1 migration tool.\n" + migrationInstructions)
44 ErrOldRepo = errors.New("ipfs repo found in old '~/.go-ipfs' location, please run migration tool.\n" + migrationInstructions)
45 )
46
47 +type NoRepoError struct {
48 + Path string
49 +}
50 +
51 +var _ error = NoRepoError{}
52 +
53 +func (err NoRepoError) Error() string {
54 + return fmt.Sprintf("no ipfs repo found in '%s'. please run: ipfs init ", err.Path)
55 +}
56 +
57 const (
58 leveldbDirectory = "datastore"
59 flatfsDirectory = "blocks"
@@ -172,7 +181,7 @@ func checkInitialized(path string) error {
181 if isInitializedUnsynced(alt) {
182 return ErrOldRepo
183 }
175 - return ErrNoRepo(path)
184 + return NoRepoError{Path: path}
185 }
186 return nil
187 }