aboutsummaryrefslogtreecommitdiff
path: root/ref/store/update_errors.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-25 14:31:16 +0000
committerGravatar Runxi Yu2026-03-25 14:31:16 +0000
commit48ff647cf4a8bb8f23fcd6b8616f56a8ef72b980 (patch)
treeae199c38042adaa544d5f7d31351661d5831381e /ref/store/update_errors.go
parent*: objectstore -> object/store (diff)
signatureNo signature
*: refstore -> ref/store
Diffstat (limited to 'ref/store/update_errors.go')
-rw-r--r--ref/store/update_errors.go110
1 files changed, 110 insertions, 0 deletions
diff --git a/ref/store/update_errors.go b/ref/store/update_errors.go
new file mode 100644
index 00000000..f05f37d2
--- /dev/null
+++ b/ref/store/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)
+}