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

Allow errors to be returned by webhook handler #712

Merged
merged 2 commits into from
Feb 15, 2022

Conversation

deniskulicek
Copy link
Contributor

Webhook event handler is currently only allowed to have :ok as a response to an event. This means that if for whatever reason we need to reject the event, Stripe sees the following 500 HTTP status code error:

{
  "status": "Internal Server Error"
}

This provides 0 context and is semantically wrong.

Changes in this PR allow for handle_event/1 functions to return :error or {:error, reason} for more context into an error that occurred. HTTP response will use 400 status code and contain the error message as a response body. Otherwise the behaviour remains unchanged and it will still raise for any other return values.

resolves #697

Copy link
Collaborator

@snewcomer snewcomer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice!

@cytex-ch
Copy link

cytex-ch commented Feb 7, 2022

Good work! Thanks @deniskulicek

@snewcomer snewcomer merged commit 78fb916 into beam-community:master Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't raise when Webhook handler returns an error tuple
3 participants