DEV Community

Discussion on: Handling stripe webhooks with Ruby on Rails

Collapse
 
gmolini profile image
Guillermo Moliní

I get a undefined method `render' for #CustomerEventHandler:0x00000003ade7a8
whenever I try to handle an error. why are you able to render json?

Collapse
 
maxencehenneron profile image
Maxence Henneron • Edited

The EventHandler is a pure ruby object, and therefore does not have any of the rails helpers. It is actually an error in my article.

If you want to raise an error when the webhook fails, you can use

rescue JSON::ParserError => e
   handle_error()
   raise  # re-raise the exception.
end

The response sent by your server will be a 500 and the webhook will fail