sailor icon indicating copy to clipboard operation
sailor copied to clipboard

Include response body in InvalidDataException

Open simPod opened this issue 1 year ago • 3 comments

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

🤷🏾‍♂️

simPod avatar Oct 08 '24 09:10 simPod

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

spawnia avatar Oct 08 '24 09:10 spawnia

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

simPod avatar Oct 08 '24 09:10 simPod

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

simPod avatar Oct 08 '24 09:10 simPod

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?

spawnia avatar Oct 17 '24 13:10 spawnia

Thanks @simPod, i released a version that has the new exception with https://github.com/spawnia/sailor/releases/tag/v0.35.0.

spawnia avatar Nov 08 '24 11:11 spawnia