diff options
Diffstat (limited to 'lib/btrfs/btrfstree/btree_err.go')
-rw-r--r-- | lib/btrfs/btrfstree/btree_err.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/btrfs/btrfstree/btree_err.go b/lib/btrfs/btrfstree/btree_err.go new file mode 100644 index 0000000..57fb283 --- /dev/null +++ b/lib/btrfs/btrfstree/btree_err.go @@ -0,0 +1,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 ¬ExistError{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 +} |