Skip to content

Commit

Permalink
[debug] improve repository err msg
Browse files Browse the repository at this point in the history
  • Loading branch information
Mcklmo committed Nov 24, 2023
1 parent 0aae805 commit db2f199
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
9 changes: 1 addition & 8 deletions pkg/http/rest/acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,7 @@ func doRequest(router *gin.Engine, path string, t *testing.T, _method method, bo

err = json.NewDecoder(response.Body).Decode(&actualResponse)
require.NoError(t, err)

if actualResponse.ErrMessage != "" {
var body interface{}
err = json.NewDecoder(response.Body).Decode(&body)

require.NoError(t, err, actualResponse.ErrMessage)
require.Empty(t, actualResponse.ErrMessage, body)
}
require.Empty(t, actualResponse.ErrMessage)

return rest.Result{
Query: actualResponse.Query,
Expand Down
7 changes: 6 additions & 1 deletion pkg/storage/virtuoso/http/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ func (r virtuosoRepository) ExecuteGET(query string) ([]graph.GetTriple, error)

virtuosoRes := graph.VirtuosoResponse{}
if err := json.Unmarshal(buf.Bytes(), &virtuosoRes); err != nil {
return nil, fmt.Errorf("unmarshal response: %w", err)
var body interface{}
if _err := json.Unmarshal(buf.Bytes(), &body); err != nil {
return nil, fmt.Errorf("unmarshal response: %w%w", _err, err)
}

return nil, fmt.Errorf("error unmarshalling response: %s, wanted %T but got %v", err.Error(), virtuosoRes, body)
}

return virtuosoRes.Results.Bindings, nil
Expand Down

0 comments on commit db2f199

Please sign in to comment.