Skip to content

Commit

Permalink
fix: Not_FOUND_PASSTHROUGH does not include error cause
Browse files Browse the repository at this point in the history
Signed-off-by: Karanjot Singh <[email protected]>
  • Loading branch information
0xquark committed Dec 28, 2024
1 parent fe4ad97 commit 8fd3c72
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions atlan/assets/errors.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package assets

import (
"encoding/json"
"fmt"
"net/http"
"io"
"encoding/json"
"net/http"
)

type ErrorInfo struct {
Expand Down Expand Up @@ -502,7 +502,7 @@ var errorCodes = map[ErrorCode]ErrorInfo{
NOT_FOUND_PASSTHROUGH: {
HTTPErrorCode: 404,
ErrorID: "ATLAN-GO-404-000",
ErrorMessage: "Server responded with %s: %s.%s",
ErrorMessage: "Server responded with %s: %s.",
UserAction: "Check the details of the server's message to correct your request.",
},
ASSET_NOT_FOUND_BY_GUID: {
Expand Down Expand Up @@ -729,17 +729,16 @@ var errorCodes = map[ErrorCode]ErrorInfo{
},
}


type Cause struct {
ErrorType string `json:"errorType"`
ErrorMessage string `json:"errorMessage"`
Location string `json:"location"`
ErrorType string `json:"errorType"`
ErrorMessage string `json:"errorMessage"`
Location string `json:"location"`
}

type ErrorResponse struct {
Causes []Cause `json:"causes"`
ErrorID string `json:"errorId"`
Message string `json:"message"`
Causes []Cause `json:"causes"`
ErrorID string `json:"errorId"`
Message string `json:"message"`
}

func handleApiError(response *http.Response, originalError error) error {
Expand All @@ -749,13 +748,13 @@ func handleApiError(response *http.Response, originalError error) error {
rc := response.StatusCode

causesString := ""
body, _ := io.ReadAll(response.Body)
var errorResponse ErrorResponse
if err := json.Unmarshal(body, &errorResponse); err == nil {
for _, cause := range errorResponse.Causes {
causesString += fmt.Sprintf(" %s : %s : %s \n", cause.ErrorType, cause.ErrorMessage, cause.Location)
}
}
body, _ := io.ReadAll(response.Body)
var errorResponse ErrorResponse
if err := json.Unmarshal(body, &errorResponse); err == nil {
for _, cause := range errorResponse.Causes {
causesString += fmt.Sprintf(" %s : %s : %s \n", cause.ErrorType, cause.ErrorMessage, cause.Location)
}
}

switch rc {
case 400:
Expand Down

0 comments on commit 8fd3c72

Please sign in to comment.