Skip to content
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

Better exception for Source.detach() on detached sources #376

Closed
jleclanche opened this issue Nov 24, 2017 · 3 comments
Closed

Better exception for Source.detach() on detached sources #376

jleclanche opened this issue Nov 24, 2017 · 3 comments
Labels

Comments

@jleclanche
Copy link
Contributor

raise NotImplementedError(

Could this get its own exception type? I want to give customers the option to remove a source from their payment methods, and right now I have to do something like this:

try:
    source.detach()
except NotImplementedError:
    resync(source)

Catching notimpl is weird, and this isn't really the appropriate exception type I think anyway.

@ob-stripe
Copy link
Contributor

Hey @jleclanche, thanks for the contribution!

Even if the exception type could be improved, I'm a bit reluctant to pull this in as it's a breaking change.

IMHO, the fact that you don't know whether a source is attached to a customer or not before calling detach() is indicative of an issue in your data model. This exception is there to point out a programming error and should not be used in regular control flows.

That said, I'll leave this open for now and ask for second opinions.

@jleclanche
Copy link
Contributor Author

@ob-stripe you can have the exception subclass NotImplementedError if you want it to be backwards-compatible.

IMHO, the fact that you don't know whether a source is attached to a customer or not before calling detach() is indicative of an issue in your data model.

I do know, but it's completely possible for data to go out of sync (eg. a second client, such as a dashboard user, can detach the source, webhooks might not trigger in time etc).

@ob-stripe
Copy link
Contributor

you can have the exception subclass NotImplementedError if you want it to be backwards-compatible.

I guess. Seems a bit hacky though!

it's completely possible for data to go out of sync (eg. a second client, such as a dashboard user, can detach the source, webhooks might not trigger in time etc).

Point taken.

We don't have firm plans yet, but there are a few backwards-incompatible changes I'd like to ship mid term. I've added your request to the list.

Tagging this as future for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants