提交 a0af9f5e 作者: Tommi Virtanen

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

上级 a7432903
...@@ -40,11 +40,20 @@ Please run the ipfs migration tool before continuing. ...@@ -40,11 +40,20 @@ Please run the ipfs migration tool before continuing.
` + migrationInstructions ` + migrationInstructions
var ( var (
ErrNoRepo = func (path string) error { return fmt.Errorf("no ipfs repo found in '%s'. please run: ipfs init ", path) }
ErrNoVersion = errors.New("no version file found, please run 0-to-1 migration tool.\n" + migrationInstructions) ErrNoVersion = errors.New("no version file found, please run 0-to-1 migration tool.\n" + migrationInstructions)
ErrOldRepo = errors.New("ipfs repo found in old '~/.go-ipfs' location, please run migration tool.\n" + migrationInstructions) ErrOldRepo = errors.New("ipfs repo found in old '~/.go-ipfs' location, please run migration tool.\n" + migrationInstructions)
) )
type NoRepoError struct {
Path string
}
var _ error = NoRepoError{}
func (err NoRepoError) Error() string {
return fmt.Sprintf("no ipfs repo found in '%s'. please run: ipfs init ", err.Path)
}
const ( const (
leveldbDirectory = "datastore" leveldbDirectory = "datastore"
flatfsDirectory = "blocks" flatfsDirectory = "blocks"
...@@ -172,7 +181,7 @@ func checkInitialized(path string) error { ...@@ -172,7 +181,7 @@ func checkInitialized(path string) error {
if isInitializedUnsynced(alt) { if isInitializedUnsynced(alt) {
return ErrOldRepo return ErrOldRepo
} }
return ErrNoRepo(path) return NoRepoError{Path: path}
} }
return nil return nil
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论