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

don't return dev messages in getUserMessage() #1940

Closed
wants to merge 2 commits into from

Conversation

xavdid-stripe
Copy link
Member

@xavdid-stripe xavdid-stripe commented Jan 23, 2025

Why?

Per guidance in V2 error guidelines, the user_message response field can be shown directly to users, but the message field is meant only for developers. The previous java implementation (#1911) conflated the two, which I worry may be confusing for users. I think the intended use case here is someting like:

  1. stripe error happened!
  2. if .getUserMessage() != null, return that to the user that triggered this action
  3. otherwise, check which error class it is and handle/log accordingly

What?

  • return null from getUserMessage() for v1 errors
  • tweak docstrings
  • simplify version checking logic
  • update test

See Also

Changelog

  • stripeException.getUserMessage() now returns null for v1 errors instead of the developer-facing message
    • getUserMessage(), if non-null, can be passed directly to your users to explain what went wrong
    • if getUserMessage() is null, then you should handle the error as usual, per the error handling docs.

@xavdid-stripe xavdid-stripe marked this pull request as draft January 23, 2025 23:10
@xavdid-stripe
Copy link
Member Author

Tabling for now, but we'll revisit in the future.

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

Successfully merging this pull request may close these issues.

1 participant