mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-29 10:41:05 -06:00
refactored RootValueUnreadable to not swallow errors
This commit is contained in:
@@ -92,10 +92,10 @@ func (cmd AddCmd) Exec(ctx context.Context, commandStr string, args []string, dE
|
||||
|
||||
func toAddVErr(err error) errhand.VerboseError {
|
||||
switch {
|
||||
case actions.IsRootValUnreachable(err):
|
||||
rt := actions.GetUnreachableRootType(err)
|
||||
case doltdb.IsRootValUnreachable(err):
|
||||
rt := doltdb.GetUnreachableRootType(err)
|
||||
bdr := errhand.BuildDError("Unable to read %s.", rt.String())
|
||||
bdr.AddCause(actions.GetUnreachableRootCause(err))
|
||||
bdr.AddCause(doltdb.GetUnreachableRootCause(err))
|
||||
return bdr.Build()
|
||||
|
||||
case actions.IsTblNotExist(err):
|
||||
|
||||
@@ -168,7 +168,7 @@ func checkoutTablesAndDocs(ctx context.Context, dEnv *env.DoltEnv, tables []stri
|
||||
err := actions.CheckoutTablesAndDocs(ctx, dEnv.DbData(), tables, docs)
|
||||
|
||||
if err != nil {
|
||||
if actions.IsRootValUnreachable(err) {
|
||||
if doltdb.IsRootValUnreachable(err) {
|
||||
return unreadableRootToVErr(err)
|
||||
} else if actions.IsTblNotExist(err) {
|
||||
badTbls := actions.GetTablesForError(err)
|
||||
@@ -193,7 +193,7 @@ func checkoutBranch(ctx context.Context, dEnv *env.DoltEnv, name string) errhand
|
||||
if err != nil {
|
||||
if err == doltdb.ErrBranchNotFound {
|
||||
return errhand.BuildDError("fatal: Branch '%s' not found.", name).Build()
|
||||
} else if actions.IsRootValUnreachable(err) {
|
||||
} else if doltdb.IsRootValUnreachable(err) {
|
||||
return unreadableRootToVErr(err)
|
||||
} else if actions.IsCheckoutWouldOverwrite(err) {
|
||||
tbls := actions.CheckoutWouldOverwriteTables(err)
|
||||
@@ -220,7 +220,7 @@ func checkoutBranch(ctx context.Context, dEnv *env.DoltEnv, name string) errhand
|
||||
}
|
||||
|
||||
func unreadableRootToVErr(err error) errhand.VerboseError {
|
||||
rt := actions.GetUnreachableRootType(err)
|
||||
rt := doltdb.GetUnreachableRootType(err)
|
||||
bdr := errhand.BuildDError("error: unable to read the %s", rt.String())
|
||||
return bdr.AddCause(actions.GetUnreachableRootCause(err)).Build()
|
||||
return bdr.AddCause(doltdb.GetUnreachableRootCause(err)).Build()
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ import (
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/diff"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/env"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/env/actions"
|
||||
"github.com/dolthub/dolt/go/libraries/doltcore/merge"
|
||||
"github.com/dolthub/dolt/go/libraries/utils/argparser"
|
||||
"github.com/dolthub/dolt/go/libraries/utils/filesys"
|
||||
@@ -346,16 +345,7 @@ func printStatus(ctx context.Context, dEnv *env.DoltEnv, stagedTbls, notStagedTb
|
||||
}
|
||||
|
||||
func toStatusVErr(err error) errhand.VerboseError {
|
||||
switch {
|
||||
case actions.IsRootValUnreachable(err):
|
||||
rt := actions.GetUnreachableRootType(err)
|
||||
bdr := errhand.BuildDError("Unable to read %s.", rt.String())
|
||||
bdr.AddCause(actions.GetUnreachableRootCause(err))
|
||||
return bdr.Build()
|
||||
|
||||
default:
|
||||
return errhand.BuildDError("Unknown error").AddCause(err).Build()
|
||||
}
|
||||
return errhand.VerboseErrorFromError(err)
|
||||
}
|
||||
|
||||
func docCnfsOnWorkingRoot(ctx context.Context, dEnv *env.DoltEnv) (bool, error) {
|
||||
|
||||
@@ -54,40 +54,6 @@ type DocDiffs struct {
|
||||
Docs []string
|
||||
}
|
||||
|
||||
type RootType int
|
||||
|
||||
func (rt RootType) String() string {
|
||||
switch rt {
|
||||
case WorkingRoot:
|
||||
return "working root"
|
||||
case StagedRoot:
|
||||
return "staged root"
|
||||
case CommitRoot:
|
||||
return "root value for commit"
|
||||
case HeadRoot:
|
||||
return "HEAD commit root value"
|
||||
}
|
||||
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
const (
|
||||
WorkingRoot RootType = iota
|
||||
StagedRoot
|
||||
CommitRoot
|
||||
HeadRoot
|
||||
InvalidRoot
|
||||
)
|
||||
|
||||
type RootValueUnreadable struct {
|
||||
rootType RootType
|
||||
Cause error
|
||||
}
|
||||
|
||||
func (rvu RootValueUnreadable) Error() string {
|
||||
return "error: Unable to read " + rvu.rootType.String()
|
||||
}
|
||||
|
||||
// NewDocDiffs returns DocDiffs for Dolt Docs between two roots.
|
||||
func NewDocDiffs(ctx context.Context, older *doltdb.RootValue, newer *doltdb.RootValue, docs doltdocs.Docs) (*DocDiffs, error) {
|
||||
var added []string
|
||||
@@ -297,17 +263,17 @@ func GetTableDeltas(ctx context.Context, fromRoot, toRoot *doltdb.RootValue) (de
|
||||
func GetStagedUnstagedTableDeltas(ctx context.Context, ddb *doltdb.DoltDB, rsr env.RepoStateReader) (staged, unstaged []TableDelta, err error) {
|
||||
headRoot, err := env.HeadRoot(ctx, ddb, rsr)
|
||||
if err != nil {
|
||||
return nil, nil, RootValueUnreadable{HeadRoot, err}
|
||||
return nil, nil, doltdb.RootValueUnreadable{doltdb.HeadRoot, err}
|
||||
}
|
||||
|
||||
stagedRoot, err := env.StagedRoot(ctx, ddb, rsr)
|
||||
if err != nil {
|
||||
return nil, nil, RootValueUnreadable{StagedRoot, err}
|
||||
return nil, nil, doltdb.RootValueUnreadable{doltdb.StagedRoot, err}
|
||||
}
|
||||
|
||||
workingRoot, err := env.WorkingRoot(ctx, ddb, rsr)
|
||||
if err != nil {
|
||||
return nil, nil, RootValueUnreadable{WorkingRoot, err}
|
||||
return nil, nil, doltdb.RootValueUnreadable{doltdb.WorkingRoot, err}
|
||||
}
|
||||
|
||||
staged, err = GetTableDeltas(ctx, headRoot, stagedRoot)
|
||||
|
||||
@@ -82,3 +82,94 @@ func IsNotACommit(err error) bool {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
type RootType int
|
||||
|
||||
const (
|
||||
WorkingRoot RootType = iota
|
||||
StagedRoot
|
||||
CommitRoot
|
||||
HeadRoot
|
||||
InvalidRoot
|
||||
)
|
||||
|
||||
func (rt RootType) String() string {
|
||||
switch rt {
|
||||
case WorkingRoot:
|
||||
return "working root"
|
||||
case StagedRoot:
|
||||
return "staged root"
|
||||
case CommitRoot:
|
||||
return "root value for commit"
|
||||
case HeadRoot:
|
||||
return "HEAD commit root value"
|
||||
}
|
||||
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
type RootTypeSet map[RootType]struct{}
|
||||
|
||||
func NewRootTypeSet(rts ...RootType) RootTypeSet {
|
||||
mp := make(map[RootType]struct{})
|
||||
|
||||
for _, rt := range rts {
|
||||
mp[rt] = struct{}{}
|
||||
}
|
||||
|
||||
return RootTypeSet(mp)
|
||||
}
|
||||
|
||||
func (rts RootTypeSet) Contains(rt RootType) bool {
|
||||
_, ok := rts[rt]
|
||||
return ok
|
||||
}
|
||||
|
||||
func (rts RootTypeSet) First(rtList []RootType) RootType {
|
||||
for _, rt := range rtList {
|
||||
if _, ok := rts[rt]; ok {
|
||||
return rt
|
||||
}
|
||||
}
|
||||
|
||||
return InvalidRoot
|
||||
}
|
||||
|
||||
func (rts RootTypeSet) IsEmpty() bool {
|
||||
return len(rts) == 0
|
||||
}
|
||||
|
||||
type RootValueUnreadable struct {
|
||||
RootType RootType
|
||||
Cause error
|
||||
}
|
||||
|
||||
func (rvu RootValueUnreadable) Error() string {
|
||||
rs, es := rvu.RootType.String(), rvu.Cause.Error()
|
||||
return fmt.Sprintf("unable to read %s: %s", rs, es)
|
||||
}
|
||||
|
||||
func IsRootValUnreachable(err error) bool {
|
||||
_, ok := err.(RootValueUnreadable)
|
||||
return ok
|
||||
}
|
||||
|
||||
func GetUnreachableRootType(err error) RootType {
|
||||
rvu, ok := err.(RootValueUnreadable)
|
||||
|
||||
if !ok {
|
||||
panic("Must validate with IsRootValUnreachable before calling GetUnreachableRootType")
|
||||
}
|
||||
|
||||
return rvu.RootType
|
||||
}
|
||||
|
||||
func GetUnreachableRootCause(err error) error {
|
||||
rvu, ok := err.(RootValueUnreadable)
|
||||
|
||||
if !ok {
|
||||
panic("Must validate with IsRootValUnreachable before calling GetUnreachableRootCause")
|
||||
}
|
||||
|
||||
return rvu.Cause
|
||||
}
|
||||
|
||||
10
go/libraries/doltcore/env/actions/branch.go
vendored
10
go/libraries/doltcore/env/actions/branch.go
vendored
@@ -218,19 +218,19 @@ func updateRootsForBranch(ctx context.Context, dbData env.DbData, dref ref.DoltR
|
||||
return hash.Hash{}, hash.Hash{}, doltdb.ErrAlreadyOnBranch
|
||||
}
|
||||
|
||||
currRoots, err := getRoots(ctx, dbData.Ddb, dbData.Rsr, HeadRoot, WorkingRoot, StagedRoot)
|
||||
currRoots, err := getRoots(ctx, dbData.Ddb, dbData.Rsr, doltdb.HeadRoot, doltdb.WorkingRoot, doltdb.StagedRoot)
|
||||
if err != nil {
|
||||
return hash.Hash{}, hash.Hash{}, err
|
||||
}
|
||||
|
||||
cs, err := doltdb.NewCommitSpec(brName)
|
||||
if err != nil {
|
||||
return hash.Hash{}, hash.Hash{}, RootValueUnreadable{HeadRoot, err}
|
||||
return hash.Hash{}, hash.Hash{}, doltdb.RootValueUnreadable{doltdb.HeadRoot, err}
|
||||
}
|
||||
|
||||
cm, err := dbData.Ddb.Resolve(ctx, cs, nil)
|
||||
if err != nil {
|
||||
return hash.Hash{}, hash.Hash{}, RootValueUnreadable{HeadRoot, err}
|
||||
return hash.Hash{}, hash.Hash{}, doltdb.RootValueUnreadable{doltdb.HeadRoot, err}
|
||||
}
|
||||
|
||||
newRoot, err := cm.GetRootValue()
|
||||
@@ -240,12 +240,12 @@ func updateRootsForBranch(ctx context.Context, dbData env.DbData, dref ref.DoltR
|
||||
|
||||
conflicts := set.NewStrSet([]string{})
|
||||
|
||||
wrkTblHashes, err := moveModifiedTables(ctx, currRoots[HeadRoot], newRoot, currRoots[WorkingRoot], conflicts)
|
||||
wrkTblHashes, err := moveModifiedTables(ctx, currRoots[doltdb.HeadRoot], newRoot, currRoots[doltdb.WorkingRoot], conflicts)
|
||||
if err != nil {
|
||||
return hash.Hash{}, hash.Hash{}, err
|
||||
}
|
||||
|
||||
stgTblHashes, err := moveModifiedTables(ctx, currRoots[HeadRoot], newRoot, currRoots[StagedRoot], conflicts)
|
||||
stgTblHashes, err := moveModifiedTables(ctx, currRoots[doltdb.HeadRoot], newRoot, currRoots[doltdb.StagedRoot], conflicts)
|
||||
if err != nil {
|
||||
return hash.Hash{}, hash.Hash{}, err
|
||||
}
|
||||
|
||||
28
go/libraries/doltcore/env/actions/checkout.go
vendored
28
go/libraries/doltcore/env/actions/checkout.go
vendored
@@ -23,13 +23,13 @@ import (
|
||||
)
|
||||
|
||||
func CheckoutAllTables(ctx context.Context, dEnv *env.DoltEnv) error {
|
||||
roots, err := getRoots(ctx, dEnv.DoltDB, dEnv.RepoStateReader(), WorkingRoot, StagedRoot, HeadRoot)
|
||||
roots, err := getRoots(ctx, dEnv.DoltDB, dEnv.RepoStateReader(), doltdb.WorkingRoot, doltdb.StagedRoot, doltdb.HeadRoot)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
tbls, err := doltdb.UnionTableNames(ctx, roots[WorkingRoot], roots[StagedRoot], roots[HeadRoot])
|
||||
tbls, err := doltdb.UnionTableNames(ctx, roots[doltdb.WorkingRoot], roots[doltdb.StagedRoot], roots[doltdb.HeadRoot])
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -42,7 +42,7 @@ func CheckoutAllTables(ctx context.Context, dEnv *env.DoltEnv) error {
|
||||
}
|
||||
|
||||
func CheckoutTables(ctx context.Context, dbData env.DbData, tables []string) error {
|
||||
roots, err := getRoots(ctx, dbData.Ddb, dbData.Rsr, WorkingRoot, StagedRoot, HeadRoot)
|
||||
roots, err := getRoots(ctx, dbData.Ddb, dbData.Rsr, doltdb.WorkingRoot, doltdb.StagedRoot, doltdb.HeadRoot)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -53,7 +53,7 @@ func CheckoutTables(ctx context.Context, dbData env.DbData, tables []string) err
|
||||
|
||||
// CheckoutTablesAndDocs takes in a set of tables and docs and checks them out to another branch.
|
||||
func CheckoutTablesAndDocs(ctx context.Context, dbData env.DbData, tables []string, docs doltdocs.Docs) error {
|
||||
roots, err := getRoots(ctx, dbData.Ddb, dbData.Rsr, WorkingRoot, StagedRoot, HeadRoot)
|
||||
roots, err := getRoots(ctx, dbData.Ddb, dbData.Rsr, doltdb.WorkingRoot, doltdb.StagedRoot, doltdb.HeadRoot)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -62,12 +62,12 @@ func CheckoutTablesAndDocs(ctx context.Context, dbData env.DbData, tables []stri
|
||||
return checkoutTablesAndDocs(ctx, dbData, roots, tables, docs)
|
||||
}
|
||||
|
||||
func checkoutTables(ctx context.Context, dbData env.DbData, roots map[RootType]*doltdb.RootValue, tbls []string) error {
|
||||
func checkoutTables(ctx context.Context, dbData env.DbData, roots map[doltdb.RootType]*doltdb.RootValue, tbls []string) error {
|
||||
unknownTbls := []string{}
|
||||
|
||||
currRoot := roots[WorkingRoot]
|
||||
staged := roots[StagedRoot]
|
||||
head := roots[HeadRoot]
|
||||
currRoot := roots[doltdb.WorkingRoot]
|
||||
staged := roots[doltdb.StagedRoot]
|
||||
head := roots[doltdb.HeadRoot]
|
||||
|
||||
for _, tblName := range tbls {
|
||||
if tblName == doltdb.DocTableName {
|
||||
@@ -119,10 +119,10 @@ func checkoutTables(ctx context.Context, dbData env.DbData, roots map[RootType]*
|
||||
return err
|
||||
}
|
||||
|
||||
func checkoutDocs(ctx context.Context, dbData env.DbData, roots map[RootType]*doltdb.RootValue, docs doltdocs.Docs) error {
|
||||
currRoot := roots[WorkingRoot]
|
||||
staged := roots[StagedRoot]
|
||||
head := roots[HeadRoot]
|
||||
func checkoutDocs(ctx context.Context, dbData env.DbData, roots map[doltdb.RootType]*doltdb.RootValue, docs doltdocs.Docs) error {
|
||||
currRoot := roots[doltdb.WorkingRoot]
|
||||
staged := roots[doltdb.StagedRoot]
|
||||
head := roots[doltdb.HeadRoot]
|
||||
|
||||
if len(docs) > 0 {
|
||||
currRootWithDocs, stagedWithDocs, updatedDocs, err := getUpdatedWorkingAndStagedWithDocs(ctx, currRoot, staged, head, docs)
|
||||
@@ -142,14 +142,14 @@ func checkoutDocs(ctx context.Context, dbData env.DbData, roots map[RootType]*do
|
||||
return dbData.Drw.WriteDocsToDisk(docs)
|
||||
}
|
||||
|
||||
func checkoutTablesAndDocs(ctx context.Context, dbData env.DbData, roots map[RootType]*doltdb.RootValue, tbls []string, docs doltdocs.Docs) error {
|
||||
func checkoutTablesAndDocs(ctx context.Context, dbData env.DbData, roots map[doltdb.RootType]*doltdb.RootValue, tbls []string, docs doltdocs.Docs) error {
|
||||
err := checkoutTables(ctx, dbData, roots, tbls)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
roots, err = getRoots(ctx, dbData.Ddb, dbData.Rsr, WorkingRoot, StagedRoot, HeadRoot)
|
||||
roots, err = getRoots(ctx, dbData.Ddb, dbData.Rsr, doltdb.WorkingRoot, doltdb.StagedRoot, doltdb.HeadRoot)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
92
go/libraries/doltcore/env/actions/errors.go
vendored
92
go/libraries/doltcore/env/actions/errors.go
vendored
@@ -77,98 +77,6 @@ func GetTablesForError(err error) []string {
|
||||
return te.tables
|
||||
}
|
||||
|
||||
type RootType int
|
||||
|
||||
const (
|
||||
WorkingRoot RootType = iota
|
||||
StagedRoot
|
||||
CommitRoot
|
||||
HeadRoot
|
||||
InvalidRoot
|
||||
)
|
||||
|
||||
var ActiveRoots = []RootType{WorkingRoot, StagedRoot, HeadRoot}
|
||||
|
||||
func (rt RootType) String() string {
|
||||
switch rt {
|
||||
case WorkingRoot:
|
||||
return "working root"
|
||||
case StagedRoot:
|
||||
return "staged root"
|
||||
case CommitRoot:
|
||||
return "root value for commit"
|
||||
case HeadRoot:
|
||||
return "HEAD commit root value"
|
||||
}
|
||||
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
type RootTypeSet map[RootType]struct{}
|
||||
|
||||
func NewRootTypeSet(rts ...RootType) RootTypeSet {
|
||||
mp := make(map[RootType]struct{})
|
||||
|
||||
for _, rt := range rts {
|
||||
mp[rt] = struct{}{}
|
||||
}
|
||||
|
||||
return RootTypeSet(mp)
|
||||
}
|
||||
|
||||
func (rts RootTypeSet) Contains(rt RootType) bool {
|
||||
_, ok := rts[rt]
|
||||
return ok
|
||||
}
|
||||
|
||||
func (rts RootTypeSet) First(rtList []RootType) RootType {
|
||||
for _, rt := range rtList {
|
||||
if _, ok := rts[rt]; ok {
|
||||
return rt
|
||||
}
|
||||
}
|
||||
|
||||
return InvalidRoot
|
||||
}
|
||||
|
||||
func (rts RootTypeSet) IsEmpty() bool {
|
||||
return len(rts) == 0
|
||||
}
|
||||
|
||||
type RootValueUnreadable struct {
|
||||
rootType RootType
|
||||
Cause error
|
||||
}
|
||||
|
||||
func (rvu RootValueUnreadable) Error() string {
|
||||
return "error: Unable to read " + rvu.rootType.String()
|
||||
}
|
||||
|
||||
func IsRootValUnreachable(err error) bool {
|
||||
_, ok := err.(RootValueUnreadable)
|
||||
return ok
|
||||
}
|
||||
|
||||
func GetUnreachableRootType(err error) RootType {
|
||||
rvu, ok := err.(RootValueUnreadable)
|
||||
|
||||
if !ok {
|
||||
panic("Must validate with IsRootValUnreachable before calling GetUnreachableRootType")
|
||||
}
|
||||
|
||||
return rvu.rootType
|
||||
}
|
||||
|
||||
func GetUnreachableRootCause(err error) error {
|
||||
rvu, ok := err.(RootValueUnreadable)
|
||||
|
||||
if !ok {
|
||||
panic("Must validate with IsRootValUnreachable before calling GetUnreachableRootCause")
|
||||
}
|
||||
|
||||
return rvu.Cause
|
||||
}
|
||||
|
||||
type CheckoutWouldOverwrite struct {
|
||||
tables []string
|
||||
}
|
||||
|
||||
16
go/libraries/doltcore/env/actions/staged.go
vendored
16
go/libraries/doltcore/env/actions/staged.go
vendored
@@ -198,34 +198,34 @@ func ValidateTables(ctx context.Context, tbls []string, roots ...*doltdb.RootVal
|
||||
}
|
||||
|
||||
func getStagedAndWorking(ctx context.Context, ddb *doltdb.DoltDB, rsr env.RepoStateReader) (*doltdb.RootValue, *doltdb.RootValue, error) {
|
||||
roots, err := getRoots(ctx, ddb, rsr, StagedRoot, WorkingRoot)
|
||||
roots, err := getRoots(ctx, ddb, rsr, doltdb.StagedRoot, doltdb.WorkingRoot)
|
||||
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return roots[StagedRoot], roots[WorkingRoot], nil
|
||||
return roots[doltdb.StagedRoot], roots[doltdb.WorkingRoot], nil
|
||||
}
|
||||
|
||||
// getRoots returns a RootValue object for each root type passed in rootTypes.
|
||||
func getRoots(ctx context.Context, ddb *doltdb.DoltDB, rsr env.RepoStateReader, rootTypes ...RootType) (map[RootType]*doltdb.RootValue, error) {
|
||||
roots := make(map[RootType]*doltdb.RootValue)
|
||||
func getRoots(ctx context.Context, ddb *doltdb.DoltDB, rsr env.RepoStateReader, rootTypes ...doltdb.RootType) (map[doltdb.RootType]*doltdb.RootValue, error) {
|
||||
roots := make(map[doltdb.RootType]*doltdb.RootValue)
|
||||
for _, rt := range rootTypes {
|
||||
var err error
|
||||
var root *doltdb.RootValue
|
||||
switch rt {
|
||||
case StagedRoot:
|
||||
case doltdb.StagedRoot:
|
||||
root, err = env.StagedRoot(ctx, ddb, rsr)
|
||||
case WorkingRoot:
|
||||
case doltdb.WorkingRoot:
|
||||
root, err = env.WorkingRoot(ctx, ddb, rsr)
|
||||
case HeadRoot:
|
||||
case doltdb.HeadRoot:
|
||||
root, err = env.HeadRoot(ctx, ddb, rsr)
|
||||
default:
|
||||
panic("Method does not support this root type.")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, RootValueUnreadable{rt, err}
|
||||
return nil, doltdb.RootValueUnreadable{rt, err}
|
||||
}
|
||||
|
||||
roots[rt] = root
|
||||
|
||||
@@ -156,8 +156,8 @@ func checkoutBranch(ctx *sql.Context, dbData env.DbData, branchName string) erro
|
||||
if err != nil {
|
||||
if err == doltdb.ErrBranchNotFound {
|
||||
return fmt.Errorf("fatal: Branch '%s' not found.", branchName)
|
||||
} else if actions.IsRootValUnreachable(err) {
|
||||
rt := actions.GetUnreachableRootType(err)
|
||||
} else if doltdb.IsRootValUnreachable(err) {
|
||||
rt := doltdb.GetUnreachableRootType(err)
|
||||
return fmt.Errorf("error: unable to read the %s", rt.String())
|
||||
} else if actions.IsCheckoutWouldOverwrite(err) {
|
||||
tbls := actions.CheckoutWouldOverwriteTables(err)
|
||||
@@ -180,8 +180,8 @@ func checkoutTables(ctx *sql.Context, dbData env.DbData, tables []string) error
|
||||
err := actions.CheckoutTables(ctx, dbData, tables)
|
||||
|
||||
if err != nil {
|
||||
if actions.IsRootValUnreachable(err) {
|
||||
rt := actions.GetUnreachableRootType(err)
|
||||
if doltdb.IsRootValUnreachable(err) {
|
||||
rt := doltdb.GetUnreachableRootType(err)
|
||||
return fmt.Errorf("error: unable to read the %s", rt.String())
|
||||
} else if actions.IsTblNotExist(err) {
|
||||
return fmt.Errorf("error: given tables do not exist")
|
||||
|
||||
Reference in New Issue
Block a user