diff --git a/lib/foodsoft_mail_receiver.rb b/lib/foodsoft_mail_receiver.rb index b84582c9b..e5250f7f8 100644 --- a/lib/foodsoft_mail_receiver.rb +++ b/lib/foodsoft_mail_receiver.rb @@ -29,10 +29,16 @@ def on_rcpt_to_event(ctx, rcpt_to) end def on_message_data_event(ctx) - @handlers.each do |handler| - handler.call(ctx[:message][:data]) + begin + @handlers.each do |handler| + handler.call(ctx[:message][:data]) + end + rescue => error + ExceptionNotifier.notify_exception(error, data: ctx) + raise error + ensure + @handlers.clear end - @handlers.clear end def self.find_handler(recipient)