From a432116ca706264266e3173516c9bfc9b8888ba7 Mon Sep 17 00:00:00 2001 From: Mohsen Haghgoo Date: Wed, 2 Oct 2024 08:27:06 +0330 Subject: [PATCH] fix(cli): return error instead fatal. --- cli/api/client.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/api/client.go b/cli/api/client.go index 3cc8a8b..e9432a3 100644 --- a/cli/api/client.go +++ b/cli/api/client.go @@ -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 { @@ -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) } defer func() { err = file.Close()