spawnia / sailor

A typesafe GraphQL client for PHP
MIT License
78 stars 18 forks source link

Include response body in InvalidDataException #112

Open simPod opened 2 weeks ago

simPod commented 2 weeks ago

Is your feature request related to a problem? Please describe.

Sometimes, it is valuable to see the error response body, not just status code because it can contain an error reason.

Describe the solution you'd like

Include body in InvalidDataException's property

Describe alternatives you've considered

🤷🏾‍♂️

spawnia commented 2 weeks ago

There are quite a few places where new InvalidDataException occurs. Is your suggestion to attach the entire reponse body to each of them?

simPod commented 2 weeks ago

I see. For now only to https://github.com/spawnia/sailor/blob/6a42958947e59fec1626e3957d9534899872cc65/src/Response.php#L35

simPod commented 2 weeks ago

But since this exception is kinda generic, the property is not appropriate.

Either introduce new exception (/subtype) or output the body (truncated?) into a message

spawnia commented 1 week ago

InvalidDataException actually seems wrong in that place, since it deals with the status code. Let's introduce a new exception type here (not a subtype, just another type). Can you provide a pull request?