Proposal to return nil
pointers instead of structs on request error
#1647
Labels
nil
pointers instead of structs on request error
#1647
Is your feature request related to a problem? Please describe.
This feature request is to track community interest in stripe-go API calls returning a
nil
pointer when the error is notnil
. The current behavior in stripe-go when the API call errors is to return both an error and a pointer to a struct with empty / zero value fields.We've recently been informed that stripe-go does not follow the typical Go convention of returning the zero value (
nil
in the case of pointers) when an API call function returns a non-nil error value. This convention is not officially documented anywhere as far as we know, but is generally followed (see this related StackOverflow post).Please feel free to upvote or comment if you would like this feature in stripe-go (or comment with arguments against making this change).
Describe the solution you'd like
In the following function call to create a new payment intent given bad params which raise an error
Old behavior:
pi
is a pointer to a struct with empty fields on errorNew behavior:
pi
isnil
on errorDescribe alternatives you've considered
No response
Additional context
Related links:
Is it conventional to return both value and error from function at the same time SO post
Stripe docs for error handling
The text was updated successfully, but these errors were encountered: