Report KeyNotFound from etcd as a 404 (#121)
This allows for proper classification of the error on the client side.
This commit is contained in:
committed by
Soam Vasani
parent
c8b5bb2972
commit
430639a1cf
@@ -263,12 +263,16 @@ func handleEtcdError(e error) error {
|
||||
}
|
||||
code := fission.ErrorInternal
|
||||
msg := ee.Error()
|
||||
simpleMsg := fmt.Sprintf("%v (%v)", ee.Message, ee.Cause)
|
||||
|
||||
//TODO: handle any other etcd error codes we care about
|
||||
switch ee.Code {
|
||||
case client.ErrorCodeNodeExist:
|
||||
code = fission.ErrorNameExists
|
||||
msg = fmt.Sprintf("%v (%v)", ee.Message, ee.Cause)
|
||||
msg = simpleMsg
|
||||
case client.ErrorCodeKeyNotFound:
|
||||
code = fission.ErrorNotFound
|
||||
msg = simpleMsg
|
||||
}
|
||||
return fission.MakeError(code, msg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user