Skip to content

Commit

Permalink
Error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
aandrew-me committed May 21, 2023
1 parent 3d569ab commit 7835ecf
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,13 @@ func codeGenerate(input string) {
fmt.Println("Status Code:", code)
os.Exit(0)
}

if jsonObj["text"] == nil {
msg := jsonObj["message"]
fmt.Printf("Error: %s\n", msg)
os.Exit(0)
}

mainText := fmt.Sprintf("%s", jsonObj["text"])

newLine = mainText
Expand Down Expand Up @@ -522,6 +529,13 @@ func getCommand(shellPrompt string) {
fmt.Println("Status Code:", code)
os.Exit(0)
}

if jsonObj["text"] == nil {
msg := jsonObj["message"]
fmt.Printf("Error: %s\n", msg)
os.Exit(0)
}

mainText := fmt.Sprintf("%s", jsonObj["text"])

newLine = mainText
Expand Down

0 comments on commit 7835ecf

Please sign in to comment.