From 56e606567c93c39aa1b1330b3bf684b3e4335d5a Mon Sep 17 00:00:00 2001 From: Karanjot Singh Date: Tue, 28 May 2024 14:12:49 +0530 Subject: [PATCH] Minor fix - Remove returning `AtlanError` while making a request (#31) * Minor fix - Remove returning AtlanError while making request Signed-off-by: Karanjot Singh * Return instead of AtlanError in throwatlanerror Signed-off-by: Karanjot Singh * Return connection error on making a delete request Signed-off-by: Karanjot Singh --------- Signed-off-by: Karanjot Singh --- atlan/client/client.go | 6 +++--- atlan/client/errors.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/atlan/client/client.go b/atlan/client/client.go index 0d6c44c..3451b5f 100644 --- a/atlan/client/client.go +++ b/atlan/client/client.go @@ -233,7 +233,7 @@ func (ac *AtlanClient) makeRequest(method, path string, params map[string]interf case http.MethodGet: req, err = http.NewRequest(method, path, nil) if err != nil { - ThrowAtlanError(err, CONNECTION_ERROR, nil) + return nil, ThrowAtlanError(err, CONNECTION_ERROR, nil) } case http.MethodPost, http.MethodPut: body, ok := params["data"].(io.Reader) @@ -242,7 +242,7 @@ func (ac *AtlanClient) makeRequest(method, path string, params map[string]interf } req, err = http.NewRequest(method, path, body) if err != nil { - ThrowAtlanError(err, CONNECTION_ERROR, nil) + return nil, ThrowAtlanError(err, CONNECTION_ERROR, nil) } req.Header.Set("Content-Type", "application/json") case http.MethodDelete: @@ -256,7 +256,7 @@ func (ac *AtlanClient) makeRequest(method, path string, params map[string]interf } req, err = http.NewRequest(method, path, body) if err != nil { - ThrowAtlanError(err, CONNECTION_ERROR, nil) + return nil, ThrowAtlanError(err, CONNECTION_ERROR, nil) } if body != nil { req.Header.Set("Content-Type", "application/json") diff --git a/atlan/client/errors.go b/atlan/client/errors.go index 78ce378..9f3e212 100644 --- a/atlan/client/errors.go +++ b/atlan/client/errors.go @@ -710,7 +710,7 @@ func handleApiError(response *http.Response, originalError error) error { return nil } -func ThrowAtlanError(err error, sdkError ErrorCode, suggestion *string, args ...interface{}) *AtlanError { +func ThrowAtlanError(err error, sdkError ErrorCode, suggestion *string, args ...interface{}) error { atlanError := AtlanError{ ErrorCode: errorCodes[sdkError], }