Skip to content

Commit

Permalink
fix: optimize error handling
Browse files Browse the repository at this point in the history
Signed-off-by: 柳丰 <[email protected]>
  • Loading branch information
imneov committed Apr 10, 2022
1 parent 525921c commit 9dad732
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions cmd/invoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,14 @@ dapr invoke --unix-domain-socket --app-id target --method sample --verb GET
var response string
if kubernetesMode {
response, err = kubernetes.Invoke(invokeAppID, invokeAppMethod, bytePayload, invokeVerb)
if err != nil {
err = fmt.Errorf("error invoking app %s: %s", invokeAppID, err)
print.FailureStatusEvent(os.Stderr, err.Error())
return
}
} else {
client := standalone.NewClient()
response, err = client.Invoke(invokeAppID, invokeAppMethod, bytePayload, invokeVerb, invokeSocket)
if err != nil {
err = fmt.Errorf("error invoking app %s: %s", invokeAppID, err)
print.FailureStatusEvent(os.Stderr, err.Error())
return
}
}
if err != nil {
err = fmt.Errorf("error invoking app %s: %s", invokeAppID, err)
print.FailureStatusEvent(os.Stderr, err.Error())
return
}

if response != "" {
Expand Down

0 comments on commit 9dad732

Please sign in to comment.