Simplify errors
This commit is contained in:
parent
e84fe44959
commit
9deae2c466
3 changed files with 5 additions and 31 deletions
|
@ -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:
|
||||
|
|
16
kvs/err.go
16
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)
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue