summaryrefslogtreecommitdiff
path: root/lib/btrfs/btrfstree/btree_err.go
blob: 57fb283e6f18e32e61ac782d15d9938e2bf6af4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright (C) 2023  Luke Shumaker <lukeshu@lukeshu.com>
//
// SPDX-License-Identifier: GPL-2.0-or-later

package btrfstree

import (
	iofs "io/fs"
)

// For both ErrNoItem and ErrNoTree, `errors.Is(err,
// io/fs.ErrNotExist)` returns true.
var (
	ErrNoItem = errNotExist("item")
	ErrNoTree = errNotExist("tree")
)

func errNotExist(thing string) error {
	return &notExistError{thing}
}

type notExistError struct {
	thing string
}

func (e *notExistError) Error() string {
	return e.thing + " does not exist"
}

func (*notExistError) Is(target error) bool {
	return target == iofs.ErrNotExist
}