Skip to content

Commit

Permalink
updated error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
sgayangi committed Jun 4, 2023
1 parent 3f850e0 commit 60916a4
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ func clientVerifyFunction(w http.ResponseWriter, r *http.Request) {

fmt.Println(resp.Header)

if resp.StatusCode == http.StatusNotFound {
fmt.Println("The function you are trying to invoke does not exist.")
errResponse.StatusCode = http.StatusNotFound
errResponse.ErrorMsg = "The function you are trying to invoke does not exist."
sendErrorResponse(w, errResponse)
return
}

// if trust headers are sent
if clientPrivKeyHex != "" && clientPubKeyHex != "" {
// Accessing the headers
Expand All @@ -162,14 +170,6 @@ func clientVerifyFunction(w http.ResponseWriter, r *http.Request) {
// Get the trust verification result
trustVerificationTag := resp.Header.Get(constants.TrustVerificationHeader)

if resp.StatusCode == http.StatusNotFound {
fmt.Println("The function you are trying to invoke does not exist.")
errResponse.StatusCode = http.StatusNotFound
errResponse.ErrorMsg = "The function you are trying to invoke does not exist."
sendErrorResponse(w, errResponse)
return
}

if serverPublicKeyHex == "" {
fmt.Println("Did not receive TruFaaS headers.")
errResponse.StatusCode = http.StatusInternalServerError
Expand Down Expand Up @@ -255,8 +255,7 @@ func fnCreate(fnName string, fileName string, env string) error {
err1 := cmd1.Run()

if err1 != nil {
return errors.New("Failed to create function. " + err1.Error())
//return errors.New(err1.Error())
return errors.New("failed to create function. The function name may already exist")
}

//Command 2: fission route create --name test --function test --url test
Expand All @@ -266,7 +265,7 @@ func fnCreate(fnName string, fileName string, env string) error {
cmd2.Stderr = os.Stderr
err2 := cmd2.Run()
if err2 != nil {
return errors.New("Failed to create route.\n " + err2.Error())
return errors.New("failed to create route. The route name may already exist")
}
return nil
}
Expand Down

0 comments on commit 60916a4

Please sign in to comment.