Skip to content

Commit

Permalink
fix err message and small change in UX
Browse files Browse the repository at this point in the history
Kubernetes-commit: ce4c793b6f1d72ecf18060d1485f2a3e4d5d8bc0
  • Loading branch information
zhengjiajin authored and k8s-publish-robot committed Jun 13, 2017
1 parent 7c6e81b commit 894ff05
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pkg/runtime/codec_check.go
Expand Up @@ -28,8 +28,7 @@ import (
// object. (Will modify internalObject.) (Assumes JSON serialization.)
// TODO: verify that the correct external version is chosen on encode...
func CheckCodec(c Codec, internalType Object, externalTypes ...schema.GroupVersionKind) error {
_, err := Encode(c, internalType)
if err != nil {
if _, err := Encode(c, internalType); err != nil {
return fmt.Errorf("Internal type not encodable: %v", err)
}
for _, et := range externalTypes {
Expand All @@ -41,9 +40,8 @@ func CheckCodec(c Codec, internalType Object, externalTypes ...schema.GroupVersi
if reflect.TypeOf(obj) != reflect.TypeOf(internalType) {
return fmt.Errorf("decode of external type %s produced: %#v", et, obj)
}
err = DecodeInto(c, exBytes, internalType)
if err != nil {
return fmt.Errorf("external type %s not convertable to internal type: %v", et, err)
if err = DecodeInto(c, exBytes, internalType); err != nil {
return fmt.Errorf("external type %s not convertible to internal type: %v", et, err)
}
}
return nil
Expand Down

0 comments on commit 894ff05

Please sign in to comment.