github.com/catandhorse/git-lfs@v2.5.2+incompatible/tq/errors.go (about)

     1  package tq
     2  
     3  import "fmt"
     4  
     5  type MalformedObjectError struct {
     6  	Name string
     7  	Oid  string
     8  
     9  	missing bool
    10  }
    11  
    12  func newObjectMissingError(name, oid string) error {
    13  	return &MalformedObjectError{Name: name, Oid: oid, missing: true}
    14  }
    15  
    16  func newCorruptObjectError(name, oid string) error {
    17  	return &MalformedObjectError{Name: name, Oid: oid, missing: false}
    18  }
    19  
    20  func (e MalformedObjectError) Missing() bool { return e.missing }
    21  
    22  func (e MalformedObjectError) Corrupt() bool { return !e.Missing() }
    23  
    24  func (e MalformedObjectError) Error() string {
    25  	if e.Corrupt() {
    26  		return fmt.Sprintf("corrupt object: %s (%s)", e.Name, e.Oid)
    27  	}
    28  	return fmt.Sprintf("missing object: %s (%s)", e.Name, e.Oid)
    29  }