Skip to content

Commit

Permalink
fix(cli): return error instead fatal.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohsen Haghgoo committed Oct 2, 2024
1 parent 5dc165e commit a432116
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cli/api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ func (c *Client) SendRequest(req types.Request) (*http.Response, error) {

reqBody, err := req.GetBody()
if err != nil {
log.Fatal(err)
return nil, err
}
r, err := http.NewRequestWithContext(context.Background(), req.Method, req.GetURL(c.config.BaseURL), reqBody)
if err != nil {
log.Fatal(err)
return nil, err
}

if req.AuthorizationRequired {
Expand All @@ -134,7 +134,7 @@ func (c *Client) checkFileExists(filePath string) bool {
func (c *Client) storeConfig() error {
file, err := os.OpenFile(configFIlePath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, configFilePermission)
if err != nil {
log.Fatalf("can't create or open file, ERR: %s", err)
return fmt.Errorf("can't create or open file, ERR: %s", err)

Check failure on line 137 in cli/api/client.go

View workflow job for this annotation

GitHub Actions / build

non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
}
defer func() {
err = file.Close()
Expand Down

0 comments on commit a432116

Please sign in to comment.