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:
Toby Crawley
2017-02-13 13:16:12 -08:00
committed by Soam Vasani
parent c8b5bb2972
commit 430639a1cf
2 changed files with 23 additions and 1 deletions
+5 -1
View File
@@ -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)
}