Fast implementation of Git in pure Go
codeberg.org/lindenii/furgit
git
go
1package errors
2
3import (
4 "fmt"
5
6 objectid "codeberg.org/lindenii/furgit/object/id"
7 objecttype "codeberg.org/lindenii/furgit/object/type"
8)
9
10// ObjectTypeError indicates that a referenced object has a different type than
11// what the operation expected.
12type ObjectTypeError struct {
13 OID objectid.ObjectID
14 Got objecttype.Type
15 Want objecttype.Type
16}
17
18// Error implements error.
19func (e *ObjectTypeError) Error() string {
20 gotName, gotOK := e.Got.Name()
21 if !gotOK {
22 gotName = fmt.Sprintf("type(%d)", e.Got)
23 }
24
25 wantName, wantOK := e.Want.Name()
26 if !wantOK {
27 wantName = fmt.Sprintf("type(%d)", e.Want)
28 }
29
30 return fmt.Sprintf("object %s has type %s, want %s", e.OID, gotName, wantName)
31}