Skip to content

Commit

Permalink
Merge pull request #9 from someengineering/lloesche/errormsg
Browse files Browse the repository at this point in the history
Add error message from server
  • Loading branch information
lloesche authored Jul 25, 2024
2 parents a1c9094 + 50aefc4 commit 59dc191
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion search/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)

Expand Down Expand Up @@ -55,7 +56,12 @@ func SearchGraph(apiEndpoint, fixJWT, workspaceID, searchStr string, withEdges b
defer resp.Body.Close()

if resp.StatusCode != 200 {
errs <- fmt.Errorf("search request failed with status code: %d", resp.StatusCode)
bodyBytes, readErr := io.ReadAll(resp.Body)
if readErr != nil {
errs <- fmt.Errorf("search request failed with status code: %d, and error reading response body: %w", resp.StatusCode, readErr)
return
}
errs <- fmt.Errorf("search request failed with status code: %d, error: %s", resp.StatusCode, string(bodyBytes))
return
}

Expand Down

0 comments on commit 59dc191

Please sign in to comment.