mdeuser commented on a change in pull request #2475: Fix error string replicate 
issue.
URL: 
https://github.com/apache/incubator-openwhisk/pull/2475#discussion_r127537589
 
 

 ##########
 File path: tools/cli/go-whisk-cli/commands/action.go
 ##########
 @@ -582,50 +582,50 @@ func getLimits(memorySet bool, logSizeSet bool, 
timeoutSet bool, memory int, log
     return limits
 }
 
-func nestedError(errorMessage string, err error) (error) {
+func nestedError(errorMessage *string, err *error) (error) {
     return whisk.MakeWskErrorFromWskError(
-        errors.New(errorMessage),
+        errors.New(*errorMessage),
         err,
         whisk.EXITCODE_ERR_GENERAL,
         whisk.DISPLAY_MSG,
         whisk.DISPLAY_USAGE)
 }
 
-func nonNestedError(errorMessage string) (error) {
+func nonNestedError(errorMessage *string) (error) {
     return whisk.MakeWskError(
-        errors.New(errorMessage),
+        errors.New(*errorMessage),
         whisk.EXITCODE_ERR_USAGE,
         whisk.DISPLAY_MSG,
         whisk.DISPLAY_USAGE)
 }
 
-func actionParseError(cmd *cobra.Command, args []string, err error) (error) {
-    whisk.Debug(whisk.DbgError, "parseAction(%s, %s) error: %s\n", cmd, args, 
err)
+func actionParseError(cmd *cobra.Command, args []string, err *error) (error) {
+    whisk.Debug(whisk.DbgError, "parseAction(%s, %s) error: %s\n", cmd, args, 
*err)
 
     errMsg := wski18n.T(
         "Invalid argument(s). {{.required}}",
         map[string]interface{}{
             "required": err,
         })
 
-    return nestedError(errMsg, err)
+    return nestedError(&errMsg, err)
 }
 
-func actionInsertError(action *whisk.Action, err error) (error) {
-    whisk.Debug(whisk.DbgError, "client.Actions.Insert(%#v, false) error: 
%s\n", action, err)
+func actionInsertError(action *whisk.Action, err *error) (error) {
+    whisk.Debug(whisk.DbgError, "client.Actions.Insert(%#v, false) error: 
%s\n", action, *err)
 
     errMsg := wski18n.T(
-        "Unable to create action '{{.name}}': {{.err}}",
+        whisk.UNABLE_CREATE_ACTION_ERR,
 
 Review comment:
   as it stands, the conversion to pointer of a subset of error structs is a 
bit confusing.  in general, the go errors package returns the error struct when 
creating one, not the pointer to the error struct
   https://golang.org/pkg/errors/
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to