etcdserver: switch to using etcd.Error

This commit is contained in:
Jonathan Boulle
2014-09-10 15:46:13 -07:00
parent 2342402434
commit e2d01eff35
3 changed files with 111 additions and 32 deletions

View File

@ -46,6 +46,7 @@ var errors = map[int]string{
EcodeIndexOrValueRequired: "Index or value is required",
EcodeIndexValueMutex: "Index and value cannot both be specified",
EcodeInvalidField: "Invalid field",
EcodeInvalidForm: "Invalid POST form",
// raft related errors
EcodeRaftInternal: "Raft Internal Error",
@ -84,6 +85,7 @@ const (
EcodeIndexOrValueRequired = 207
EcodeIndexValueMutex = 208
EcodeInvalidField = 209
EcodeInvalidForm = 210
EcodeRaftInternal = 300
EcodeLeaderElect = 301
@ -104,6 +106,10 @@ type Error struct {
Index uint64 `json:"index"`
}
func NewRequestError(errorCode int, cause string) *Error {
return NewError(errorCode, cause, 0)
}
func NewError(errorCode int, cause string, index uint64) *Error {
return &Error{
ErrorCode: errorCode,