1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
package errors
import (
"fmt"
)
// noSuchObject is an error type that occurs when no object with a given object
// ID is available.
type noSuchObject struct {
oid []byte
}
// Error implements the error.Error() function.
func (e *noSuchObject) Error() string {
return fmt.Sprintf("gitobj: no such object: %x", e.oid)
}
// NoSuchObject creates a new error representing a missing object with a given
// object ID.
func NoSuchObject(oid []byte) error {
return &noSuchObject{oid: oid}
}
// IsNoSuchObject indicates whether an error is a noSuchObject and is non-nil.
func IsNoSuchObject(e error) bool {
err, ok := e.(*noSuchObject)
return ok && err != nil
}
|