Skip to content

Instantly share code, notes, and snippets.

@reidab
Created February 2, 2023 19:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reidab/f3b34df17e68f40fb6069d915e7ad62b to your computer and use it in GitHub Desktop.
Save reidab/f3b34df17e68f40fb6069d915e7ad62b to your computer and use it in GitHub Desktop.
diff --git a/app/controllers/api/v6/availability_scan_checkouts_controller.rb b/app/controllers/api/v6/availability_scan_checkouts_controller.rb
index 0d15a9270..42fd2b301 100644
--- a/app/controllers/api/v6/availability_scan_checkouts_controller.rb
+++ b/app/controllers/api/v6/availability_scan_checkouts_controller.rb
@@ -18,9 +18,11 @@ module Api
render_checkout_response(payment_intent)
rescue ActiveRecord::RecordNotFound
- render json: { error: { code: 404, message: 'No default Dyrt Alert plan available' } }
- rescue Stripe::InvalidRequestError, Stripe::StripeError
- render json: { error: { code: 500, message: 'Unable to generate Stripe payment intent sucessfully' } }
+ render json: { errors: [{ status: '404', title: 'No default Dyrt Alert plan available' }] }, status: :not_found
+ rescue Stripe::InvalidRequestError, Stripe::StripeError => e
+ render json: { errors: [{ status: '500', title: 'Unable to generate Stripe payment intent sucessfully' }] }, status: :internal_server_error
+
+ Sentry.capture_exception(e)
end
def update
@@ -33,9 +35,11 @@ module Api
render_checkout_response(payment_intent)
rescue ActiveRecord::RecordNotFound
- render json: { error: { code: 404, message: 'Invalid sku, Dyrt Alert plan not found' } }
+ render json: { errors: [{ status: '404', title: 'Invalid sku, Dyrt Alert plan not found' }] }, status: :not_found
rescue Stripe::InvalidRequestError, Stripe::StripeError
- render json: { error: { code: 500, message: 'Unable to update Stripe payment intent sucessfully' } }
+ render json: { errors: [{ status: '500', title: 'Unable to update Stripe payment intent sucessfully' }] }
+
+ Sentry.capture_exception(e)
end
private
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment