Skip to content

Commit

Permalink
add custom txn conflict error
Browse files Browse the repository at this point in the history
  • Loading branch information
fredcarle committed Dec 19, 2022
1 parent ede4022 commit 4df2b24
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion datastore/memory/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,15 @@ import "github.com/sourcenetwork/defradb/errors"
var (
ErrReadOnlyTxn = errors.New("read only transaction")
ErrTxnDiscarded = errors.New("transaction discarded")
ErrTxnConflict = errors.New("transaction conflict")
ErrTxnConflict = txnConflictError{errors.New("transaction conflict")}
)

type txnConflictError struct {
error
}

// custom error formatting that is non idiomatic but matches the
// Badger transaction conflict message
func (e txnConflictError) Error() string {
return "Transaction Conflict. Please retry"
}

0 comments on commit 4df2b24

Please sign in to comment.