github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/ledger/errors.go (about) 1 package ledger 2 3 // ErrLedgerConstruction is returned upon a failure in ledger creation steps 4 type ErrLedgerConstruction struct { 5 Err error 6 } 7 8 func (e ErrLedgerConstruction) Error() string { 9 return e.Err.Error() 10 } 11 12 // Is returns true if the type of errors are the same 13 func (e ErrLedgerConstruction) Is(other error) bool { 14 _, ok := other.(ErrLedgerConstruction) 15 return ok 16 } 17 18 // NewErrLedgerConstruction constructs a new ledger construction error 19 func NewErrLedgerConstruction(err error) *ErrLedgerConstruction { 20 return &ErrLedgerConstruction{err} 21 } 22 23 // ErrMissingKeys is returned when some keys are not found in the ledger 24 // this is mostly used when dealing with partial ledger 25 type ErrMissingKeys struct { 26 Keys []Key 27 } 28 29 func (e ErrMissingKeys) Error() string { 30 str := "keys are missing: \n" 31 for _, k := range e.Keys { 32 str += "\t" + k.String() + "\n" 33 } 34 return str 35 } 36 37 // Is returns true if the type of errors are the same 38 func (e ErrMissingKeys) Is(other error) bool { 39 _, ok := other.(ErrMissingKeys) 40 return ok 41 } 42 43 // TODO add more errors 44 // ErrorFetchQuery 45 // ErrorCommitChanges 46 // ErrorMissingKeys