diff --git a/db/executor.go b/db/executor.go index d5497585..3716930c 100644 --- a/db/executor.go +++ b/db/executor.go @@ -492,8 +492,6 @@ func status(e error) (s string) { return "OK" case *kvs.DBError: return "ERR_DB" - case *kvs.KVError: - return "ERR_KV" case *PermsError: return "ERR_PE" case *ExistError: diff --git a/kvs/err.go b/kvs/err.go index 637bb79d..adbf5c4e 100644 --- a/kvs/err.go +++ b/kvs/err.go @@ -24,19 +24,5 @@ type DBError struct { // Error returns the string representation of the error. func (e *DBError) Error() string { - return fmt.Sprintf("Unable to write to the database") -} - -// KVError is an error which occurs when there is a -// problem with a conditional put or delete. -type KVError struct { - Err error - Key []byte - Val []byte - Exp []byte -} - -// Error returns the string representation of the error. -func (e *KVError) Error() string { - return fmt.Sprintf("Database record already exists") + return fmt.Sprintf("Unable to write to the database: %s", e.Err) } diff --git a/kvs/rixxdb/tx.go b/kvs/rixxdb/tx.go index 67b31582..27e6a8bc 100644 --- a/kvs/rixxdb/tx.go +++ b/kvs/rixxdb/tx.go @@ -27,13 +27,8 @@ type TX struct { func one(res *rixxdb.KV, err error) (kvs.KV, error) { - switch err { - case nil: - break - default: - return nil, &kvs.DBError{} - case rixxdb.ErrTxNotExpectedValue: - return nil, &kvs.KVError{} + if err != nil { + return nil, &kvs.DBError{Err: err} } return res, err @@ -42,13 +37,8 @@ func one(res *rixxdb.KV, err error) (kvs.KV, error) { func many(res []*rixxdb.KV, err error) ([]kvs.KV, error) { - switch err { - case nil: - break - default: - return nil, &kvs.DBError{} - case rixxdb.ErrTxNotExpectedValue: - return nil, &kvs.KVError{} + if err != nil { + return nil, &kvs.DBError{Err: err} } var out = make([]kvs.KV, len(res))