Skip to content

Commit

Permalink
Capture webhook errors in Sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
zachgoll committed Feb 7, 2025
1 parent 972c850 commit 331de2f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/controllers/webhooks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def plaid

render json: { received: true }, status: :ok
rescue => error
Sentry.capture_exception(error)
render json: { error: "Invalid webhook: #{error.message}" }, status: :bad_request
end

Expand All @@ -33,10 +34,12 @@ def stripe
Rails.logger.info "Unhandled event type: #{event.type}"
end

rescue JSON::ParserError
rescue JSON::ParserError => error
Sentry.capture_exception(error)
render json: { error: "Invalid payload" }, status: :bad_request
return
rescue Stripe::SignatureVerificationError
rescue Stripe::SignatureVerificationError => error
Sentry.capture_exception(error)
render json: { error: "Invalid signature" }, status: :bad_request
return
end
Expand Down

0 comments on commit 331de2f

Please sign in to comment.