From b8179d74182932d0e6db149b5d012dfd79866cc3 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Mon, 8 Jun 2026 07:00:01 +0000 Subject: errs: Add --- errs/doc.go | 2 ++ errs/missing.go | 25 +++++++++++++++++++++++++ errs/type.go | 24 ++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 errs/doc.go create mode 100644 errs/missing.go create mode 100644 errs/type.go diff --git a/errs/doc.go b/errs/doc.go new file mode 100644 index 00000000..f9891334 --- /dev/null +++ b/errs/doc.go @@ -0,0 +1,2 @@ +// Package errs defines error types shared across furgit. +package errs diff --git a/errs/missing.go b/errs/missing.go new file mode 100644 index 00000000..0630846c --- /dev/null +++ b/errs/missing.go @@ -0,0 +1,25 @@ +package errs + +import ( + "fmt" + + "lindenii.org/go/furgit/object/id" +) + +// ObjectMissingError indicates that +// a referenced object is absent from the repository object store. +// +// This should only be used +// in situations where objects are being queried recursively +// or otherwise by some chain that the caller may not be aware of. +// +// Failures on direct object access +// should instead use [lindenii.org/go/furgit/object/store.ErrObjectNotFound]. +type ObjectMissingError struct { + OID id.ObjectID +} + +// Error implements error. +func (e *ObjectMissingError) Error() string { + return fmt.Sprintf("missing object %s", e.OID) +} diff --git a/errs/type.go b/errs/type.go new file mode 100644 index 00000000..f726e89b --- /dev/null +++ b/errs/type.go @@ -0,0 +1,24 @@ +package errs + +import ( + "fmt" + + "lindenii.org/go/furgit/object/id" + "lindenii.org/go/furgit/object/typ" +) + +// ObjectTypeError indicates that a referenced object +// has a different type than what the operation expected. +type ObjectTypeError struct { + OID id.ObjectID + Got typ.Type + Want typ.Type +} + +// Error implements error. +func (e *ObjectTypeError) Error() string { + return fmt.Sprintf( + "object %s has type %s, want %s", + e.OID, e.Got.Name(), e.Want.Name(), + ) +} -- cgit v1.3.1-10-gc9f91