summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-04-17 19:06:26 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2023-04-17 19:52:26 -0600
commit7bd942c1e5f8d4a18f7e1ac866191d8f1aa31d30 (patch)
treec37fbbb12d79b2d5c87a96f0e2770d22934eab91
parent6b521d08bbb75430432834e5fcd2cb1da3de1e2e (diff)
btrfsutil: RebuiltForrest: Fuss with error messages
-rw-r--r--lib/btrfsutil/rebuilt_forrest.go9
-rw-r--r--lib/btrfsutil/rebuilt_forrest_test.go2
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/btrfsutil/rebuilt_forrest.go b/lib/btrfsutil/rebuilt_forrest.go
index 3e40103..79d8beb 100644
--- a/lib/btrfsutil/rebuilt_forrest.go
+++ b/lib/btrfsutil/rebuilt_forrest.go
@@ -214,7 +214,8 @@ func (ts *RebuiltForrest) rebuildTree(ctx context.Context, treeID btrfsprim.ObjI
default:
rootOff, rootItem, err := ts.cb.LookupRoot(ctx, treeID)
if err != nil {
- ts.trees[treeID].rootErr = fmt.Errorf("%w: %s", btrfstree.ErrNoTree, err)
+ ts.trees[treeID].rootErr = fmt.Errorf("tree %s: %w: %s",
+ treeID.Format(btrfsprim.ROOT_TREE_OBJECTID), btrfstree.ErrNoTree, err)
return
}
ts.trees[treeID].Root = rootItem.ByteNr
@@ -223,7 +224,8 @@ func (ts *RebuiltForrest) rebuildTree(ctx context.Context, treeID btrfsprim.ObjI
ts.trees[treeID].ParentGen = rootOff
parentID, err := ts.cb.LookupUUID(ctx, rootItem.ParentUUID)
if err != nil {
- err := fmt.Errorf("failed to look up UUID: %v: %w", rootItem.ParentUUID, err)
+ err := fmt.Errorf("tree %s: failed to look up UUID: %v: %w",
+ treeID.Format(btrfsprim.ROOT_TREE_OBJECTID), rootItem.ParentUUID, err)
if ts.laxAncestors {
ts.trees[treeID].parentErr = err
} else {
@@ -238,7 +240,8 @@ func (ts *RebuiltForrest) rebuildTree(ctx context.Context, treeID btrfsprim.ObjI
ts.trees[treeID].ancestorLoop = true
return
case !ts.laxAncestors && ts.trees[treeID].Parent.rootErr != nil:
- ts.trees[treeID].rootErr = fmt.Errorf("failed to rebuild parent tree: %v: %w", parentID, ts.trees[treeID].Parent.rootErr)
+ ts.trees[treeID].rootErr = fmt.Errorf("tree %s: failed to rebuild parent: %w",
+ treeID.Format(btrfsprim.ROOT_TREE_OBJECTID), ts.trees[treeID].Parent.rootErr)
return
}
}
diff --git a/lib/btrfsutil/rebuilt_forrest_test.go b/lib/btrfsutil/rebuilt_forrest_test.go
index 86ae9a7..bb7b698 100644
--- a/lib/btrfsutil/rebuilt_forrest_test.go
+++ b/lib/btrfsutil/rebuilt_forrest_test.go
@@ -225,7 +225,7 @@ func TestRebuiltTreeParentErr(t *testing.T) {
rfs := NewRebuiltForrest(nil, Graph{}, cbs, false)
tree, err := rfs.RebuiltTree(ctx, 305)
- assert.EqualError(t, err, `failed to rebuild parent tree: 304: tree does not exist: item does not exist`)
+ assert.EqualError(t, err, `tree 305: failed to rebuild parent: tree 304: tree does not exist: item does not exist`)
assert.Nil(t, tree)
})