Skip to content

Commit

Permalink
💪 make error messages better
Browse files Browse the repository at this point in the history
  • Loading branch information
Omochice committed Sep 24, 2021
1 parent 88c0f78 commit 5ad8c57
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,8 @@ func LoadSettings(c *cli.Context) (Setting, error) {
}

if (setting.SourceLang == setting.TargetLang) && (setting.SourceLang == "FILLIN" || setting.TargetLang == "FILLIN") {
return setting, fmt.Errorf("Invalid source_lang and target_lang\n\tCheck %s.", configPath)
return setting, fmt.Errorf("Invalid source_lang and target_lang\n\tCheck %s or arguments.", configPath)
}

return setting, nil
}

Expand Down Expand Up @@ -145,9 +144,14 @@ func ParseResponse(resp *http.Response) (Response, error) {
body, err := ioutil.ReadAll(resp.Body)

if err != nil {
err := fmt.Errorf("%s (occurred while parse response)", err.Error())
return responseJson, err
}
err = json.Unmarshal(body, &responseJson)
if err != nil {
err := fmt.Errorf("%s (occurred while parse response)", err.Error())
return responseJson, err
}
return responseJson, err
}

Expand Down

0 comments on commit 5ad8c57

Please sign in to comment.