github.com/ipld/go-ipld-prime@v0.21.0/linking/errors.go (about) 1 package linking 2 3 import ( 4 "fmt" 5 6 "github.com/ipld/go-ipld-prime/datamodel" 7 ) 8 9 // ErrLinkingSetup is returned by methods on LinkSystem when some part of the system is not set up correctly, 10 // or when one of the components refuses to handle a Link or LinkPrototype given. 11 // (It is not yielded for errors from the storage nor codec systems once they've started; those errors rise without interference.) 12 type ErrLinkingSetup struct { 13 Detail string // Perhaps an enum here as well, which states which internal function was to blame? 14 Cause error 15 } 16 17 func (e ErrLinkingSetup) Error() string { return fmt.Sprintf("%s: %v", e.Detail, e.Cause) } 18 func (e ErrLinkingSetup) Unwrap() error { return e.Cause } 19 20 // ErrHashMismatch is the error returned when loading data and verifying its hash 21 // and finding that the loaded data doesn't re-hash to the expected value. 22 // It is typically seen returned by functions like LinkSystem.Load or LinkSystem.Fill. 23 type ErrHashMismatch struct { 24 Actual datamodel.Link 25 Expected datamodel.Link 26 } 27 28 func (e ErrHashMismatch) Error() string { 29 return fmt.Sprintf("hash mismatch! %v (actual) != %v (expected)", e.Actual, e.Expected) 30 }