New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add public models for errors #678
Conversation
I don't think it's worth doing this now. We should do it in 8.X which @mickjermsurawong-stripe has already planned per the code here |
ah thank you @ob-stripe for taking the The 8.0 will have this new structure that has // replacing StripeErrorContainer
public class StripeErrorResponse extends StripeObject {
@SerializedName("error")
StripeError error;
}
// actual error content
public class StripeError {
String docUrl;
...
}
public class PaymentIntent extends ApiResource implements HasId, MetadataStore<PaymentIntent> {
/** The payment error encountered in the previous PaymentIntent confirmation. */
@SerializedName("last_payment_error")
StripeError lastPaymentError;
} And stripe error now has This is the impact of the proposed change Please let me know if you have feedback on the new structure! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't fully understand this change and why it's not a breaking change since you seemed to move things around like declineCode
and param
disappearing.
Will defer to @mickjermsurawong-stripe who will likely better understand this.
I just opportunistically removed the manually defined getters in favor of Lombok's |
@mickjermsurawong-stripe I think this should largely be compatible with the 8.0 branch. Unless I missed something, the only notable difference is that I'm not exposing a |
ack @ob-stripe will give a thorough review again! |
I'm wondering if we should rename |
@mickjermsurawong-stripe What if I renamed |
Ah yup, explicit documentation would address the concern I had too. Given that Other than that, the code this looks great to me. As you mentioned, this is indeed compatible with 8.0, except for Thank you @ob-stripe for the fix! Please feel free to self-approve this after the changes! (I'm afraid another round of time-zone waiting for my stamp will block you unnecessarily) ptal @ob-stripe |
Released as 7.22.0. |
r? @mickjermsurawong-stripe @remi-stripe
cc @scherr-stripe
This PR adds two new publicly exposed models:
com.stripe.model.StripeError
for regular API errorscom.stripe.model.oauth.OAuthError
for OAuth errorsStripeException
now has agetError()
accessors that returns theStripeError
instance, and similarlyOAuthException
has agetOauthError()
that returns theOAuthError
instance (overridinggetError()
isn't possible becauseStripeError
andOAuthError
aren't covariant).Users can now also access the
StripeResponse
viagetLastResponse()
on theStripeError
/OAuthError
instance.(I've also removed the manually defined getters in exception classes in favor of
@Getter
.)