Explorar el Código

Merge pull request #19131 from cpuguy83/fix_plugin_error_handling

Don't error out on plugin err with json
Antonio Murdaca hace 9 años
padre
commit
f4f848b7a5
Se han modificado 1 ficheros con 4 adiciones y 5 borrados
  1. 4 5
      pkg/plugins/client.go

+ 4 - 5
pkg/plugins/client.go

@@ -134,11 +134,10 @@ func (c *Client) callWithRetry(serviceMethod string, data io.Reader, retry bool)
 				Err string
 			}
 			remoteErr := responseErr{}
-			if err := json.Unmarshal(b, &remoteErr); err != nil {
-				return nil, fmt.Errorf("%s: %s", serviceMethod, err)
-			}
-			if remoteErr.Err != "" {
-				return nil, fmt.Errorf("%s: %s", serviceMethod, remoteErr.Err)
+			if err := json.Unmarshal(b, &remoteErr); err == nil {
+				if remoteErr.Err != "" {
+					return nil, fmt.Errorf("%s: %s", serviceMethod, remoteErr.Err)
+				}
 			}
 			// old way...
 			return nil, fmt.Errorf("%s: %s", serviceMethod, string(b))