Skip to content

Commit

Permalink
include request id in test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cewkrupa committed Nov 20, 2024
1 parent 0ddd75a commit c81e65d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions client/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package client
import (
"encoding/json"
"errors"
"fmt"
"net/http"

"github.com/hashicorp/jsonapi"
Expand Down Expand Up @@ -65,9 +66,8 @@ func (e *DetailedError) IsNotFound() bool {

// Error returns a pretty-printed representation of the error
func (e DetailedError) Error() string {
response := fmt.Sprintf("ID: %s\n", e.ID)
if len(e.Details) > 0 {
var response string

for index, details := range e.Details {
response += details.String()

Expand All @@ -81,7 +81,7 @@ func (e DetailedError) Error() string {
return response
}

return e.Message
return response + e.Message
}

func ErrorFromResponse(r *http.Response) error {
Expand Down

0 comments on commit c81e65d

Please sign in to comment.