aboutsummaryrefslogtreecommitdiff
path: root/ref/store/errors.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-06-24 14:52:28 +0000
committerGravatar Runxi Yu2026-06-24 14:53:00 +0000
commitdb5e5eb40d7f8652383099a2154f00158aa476c2 (patch)
treee8c60130234137fc59505a360e804917f6c6f01e /ref/store/errors.go
parentTODO: maint, gc (diff)
ref/store{,/memory}: Add
Diffstat (limited to 'ref/store/errors.go')
-rw-r--r--ref/store/errors.go77
1 files changed, 77 insertions, 0 deletions
diff --git a/ref/store/errors.go b/ref/store/errors.go
new file mode 100644
index 00000000..64666ee6
--- /dev/null
+++ b/ref/store/errors.go
@@ -0,0 +1,77 @@
+package store
+
+import (
+ "errors"
+ "fmt"
+
+ "lindenii.org/go/furgit/object/id"
+)
+
+// ErrReferenceNotFound indicates that a reference does not exist in a backend.
+var ErrReferenceNotFound = errors.New("ref/store: reference not found")
+
+// ErrCreateExists indicates that a create operation
+// targeted an already-existing reference.
+var ErrCreateExists = errors.New("ref/store: reference already exists")
+
+// ErrDuplicateUpdate indicates that one transaction or batch
+// includes a duplicate resolved update target.
+var ErrDuplicateUpdate = errors.New("ref/store: duplicate reference update")
+
+// ErrExpectedDirect indicates that an operation required a direct reference
+// but found a different kind.
+var ErrExpectedDirect = errors.New("ref/store: expected direct reference")
+
+// ErrExpectedSymbolic indicates that an operation required a symbolic reference
+// but found a different kind.
+var ErrExpectedSymbolic = errors.New("ref/store: expected symbolic reference")
+
+// ErrInvalidValue indicates that a requested reference value is invalid,
+// such as an empty symbolic target
+// or an object ID whose format does not match the store.
+var ErrInvalidValue = errors.New("ref/store: invalid reference value")
+
+// ErrSymbolicCycle indicates that resolving a symbolic reference
+// encountered a cycle.
+var ErrSymbolicCycle = errors.New("ref/store: symbolic reference cycle")
+
+// NameConflictError indicates that one reference name conflicts with another
+// visible or queued reference name.
+type NameConflictError struct {
+ Other string
+}
+
+// Error implements error.
+func (err *NameConflictError) Error() string {
+ return fmt.Sprintf("ref/store: reference name conflict with %q", err.Other)
+}
+
+// WrongOldIDError indicates that a direct operation's expected old object ID
+// did not match the current reference value.
+type WrongOldIDError struct {
+ Actual id.ObjectID
+ Expected id.ObjectID
+}
+
+// Error implements error.
+func (err *WrongOldIDError) Error() string {
+ return fmt.Sprintf(
+ "ref/store: incorrect old object id: got %s, expected %s",
+ err.Actual, err.Expected,
+ )
+}
+
+// WrongOldTargetError indicates that a symbolic operation's expected old target
+// did not match the current reference target.
+type WrongOldTargetError struct {
+ Actual string
+ Expected string
+}
+
+// Error implements error.
+func (err *WrongOldTargetError) Error() string {
+ return fmt.Sprintf(
+ "ref/store: incorrect old target: got %q, expected %q",
+ err.Actual, err.Expected,
+ )
+}