aboutsummaryrefslogtreecommitdiff
path: root/refstore/update_errors.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-23 03:25:44 +0000
committerGravatar Runxi Yu2026-03-23 03:27:52 +0000
commit4a796e64ac576d6a3e3f2fe6174c4aa476ea0c5c (patch)
tree44d72a20076ceab0981d0b553693d26ca36cc0be /refstore/update_errors.go
parentreceivepack: Lifecycle/ownership docs (diff)
signatureNo signature
refstore: Improve interfaces, errors, and make batch work v0.1.92
Diffstat (limited to 'refstore/update_errors.go')
-rw-r--r--refstore/update_errors.go110
1 files changed, 110 insertions, 0 deletions
diff --git a/refstore/update_errors.go b/refstore/update_errors.go
new file mode 100644
index 00000000..f05f37d2
--- /dev/null
+++ b/refstore/update_errors.go
@@ -0,0 +1,110 @@
+package refstore
+
+import "fmt"
+
+// InvalidNameError indicates that one requested reference name is invalid.
+type InvalidNameError struct {
+ Err error
+}
+
+func (err *InvalidNameError) Error() string {
+ if err == nil || err.Err == nil {
+ return "invalid reference name"
+ }
+
+ return fmt.Sprintf("invalid reference name: %v", err.Err)
+}
+
+func (err *InvalidNameError) Unwrap() error {
+ if err == nil {
+ return nil
+ }
+
+ return err.Err
+}
+
+// InvalidValueError indicates that one requested reference value is invalid.
+type InvalidValueError struct {
+ Err error
+}
+
+func (err *InvalidValueError) Error() string {
+ if err == nil || err.Err == nil {
+ return "invalid reference value"
+ }
+
+ return fmt.Sprintf("invalid reference value: %v", err.Err)
+}
+
+func (err *InvalidValueError) Unwrap() error {
+ if err == nil {
+ return nil
+ }
+
+ return err.Err
+}
+
+// DuplicateUpdateError indicates that one batch or transaction includes a
+// duplicate update target.
+type DuplicateUpdateError struct{}
+
+func (err *DuplicateUpdateError) Error() string {
+ return "duplicate reference update"
+}
+
+// CreateExistsError indicates that one create operation targeted an existing
+// reference.
+type CreateExistsError struct{}
+
+func (err *CreateExistsError) Error() string {
+ return "reference already exists"
+}
+
+// IncorrectOldValueError indicates that one operation's expected old value did
+// not match the current reference value.
+type IncorrectOldValueError struct {
+ Actual string
+ Expected string
+}
+
+func (err *IncorrectOldValueError) Error() string {
+ if err == nil {
+ return "incorrect old value provided"
+ }
+
+ if err.Actual == "" && err.Expected == "" {
+ return "incorrect old value provided"
+ }
+
+ return fmt.Sprintf("incorrect old value provided: got %q, expected %q", err.Actual, err.Expected)
+}
+
+// ExpectedDetachedError indicates that one operation required a detached
+// reference but found a different kind.
+type ExpectedDetachedError struct{}
+
+func (err *ExpectedDetachedError) Error() string {
+ return "expected detached reference"
+}
+
+// ExpectedSymbolicError indicates that one operation required a symbolic
+// reference but found a different kind.
+type ExpectedSymbolicError struct{}
+
+func (err *ExpectedSymbolicError) Error() string {
+ return "expected symbolic reference"
+}
+
+// NameConflictError indicates that one reference name conflicts with another
+// visible or queued reference name.
+type NameConflictError struct {
+ Other string
+}
+
+func (err *NameConflictError) Error() string {
+ if err == nil || err.Other == "" {
+ return "reference name conflict"
+ }
+
+ return fmt.Sprintf("reference name conflict with %q", err.Other)
+}