Skip to content

Commit

Permalink
Minor fix - Remove returning AtlanError while making a request (#31)
Browse files Browse the repository at this point in the history
* Minor fix - Remove returning AtlanError while making request

Signed-off-by: Karanjot Singh <[email protected]>

* Return  instead of AtlanError in throwatlanerror

Signed-off-by: Karanjot Singh <[email protected]>

* Return connection error on making a delete request

Signed-off-by: Karanjot Singh <[email protected]>

---------

Signed-off-by: Karanjot Singh <[email protected]>
  • Loading branch information
0xquark authored May 28, 2024
1 parent cd7e289 commit 56e6065
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions atlan/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion atlan/client/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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],
}
Expand Down

0 comments on commit 56e6065

Please sign in to comment.