diff --git a/handler.go b/handler.go index 0cfdc2b..8b687e7 100644 --- a/handler.go +++ b/handler.go @@ -20,6 +20,7 @@ func handleRequest[T any](client *http.Client, req *http.Request) (*T, error) { } resp.Error.Time = resp.Time + resp.Error.RawQuery = req.URL.RawQuery return nil, resp.Error } diff --git a/types.go b/types.go index dc4f080..a0ebb8e 100644 --- a/types.go +++ b/types.go @@ -559,12 +559,13 @@ type Offer struct { } type ErrorResponse struct { - ID string `json:"id"` - Status int `json:"status"` - Code string `json:"code"` - Detail string `json:"detail"` - Meta ErrorMeta `json:"meta"` - Time *Timestamp `json:"-"` + ID string `json:"id"` + Status int `json:"status"` + Code string `json:"code"` + Detail string `json:"detail"` + Meta ErrorMeta `json:"meta"` + RawQuery string `json:"raw_query"` + Time *Timestamp `json:"-"` } func (er ErrorResponse) Error() string { @@ -583,8 +584,8 @@ func (er ErrorResponse) Format(f fmt.State, c rune) { e.Type, strings.Join(e.Loc, "."), e.Input, e.Message)) } - fmt.Fprintf(f, "error: %s (ID: %s; Status: %d; Code: %s); details: %s", - er.Detail, er.ID, er.Status, er.Code, strings.Join(meta, ", ")) + fmt.Fprintf(f, "error: %s (ID: %s; Status: %d; Code: %s RawQuery: %s); details: %s", + er.Detail, er.ID, er.Status, er.Code, strings.Join(meta, ", "), er.RawQuery) } else { fmt.Fprint(f, er.Detail) } diff --git a/types_test.go b/types_test.go index 3057462..d9f1a17 100644 --- a/types_test.go +++ b/types_test.go @@ -32,7 +32,7 @@ func TestErrorResponse(t *testing.T) { p := fmt.Sprintf("%+v", resp) assert.Equal(t, - "error: Unable to validate request parameter(s) (ID: f49c8ffa-5ddc-4fbf-9841-6b3093c21eb2; Status: 422; Code: VALIDATION); details: (type [int_parsing]; loc [query.offset]; input [foo]; msg [Input should be a valid integer, unable to parse string as an integer])", + "error: Unable to validate request parameter(s) (ID: f49c8ffa-5ddc-4fbf-9841-6b3093c21eb2; Status: 422; Code: VALIDATION RawQuery: (type [int_parsing]; loc [query.offset]; input [foo]; msg [Input should be a valid integer, unable to parse string as an integer])); details: ", p, ) }