From 5543b05c12069784e8f663193e4f4904337f7697 Mon Sep 17 00:00:00 2001 From: 7riumph Date: Wed, 26 Feb 2025 12:22:05 -0700 Subject: [PATCH] Added volunteer invitation error handling --- app/controllers/volunteers_controller.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/controllers/volunteers_controller.rb b/app/controllers/volunteers_controller.rb index 8c01f9a861..9fa8a11885 100644 --- a/app/controllers/volunteers_controller.rb +++ b/app/controllers/volunteers_controller.rb @@ -32,7 +32,16 @@ def create authorize @volunteer if @volunteer.save && @volunteer.email.match?(URI::MailTo::EMAIL_REGEXP) - @volunteer.invite!(current_user) + + # invitation error handling + begin + @volunteer.invite!(current_user) + rescue ActiveRecord::RecordInvalid, StandardError => e + logger.error "Volunteer invitation failed: #{e.message}" + else + logger.info "Volunteer invitation sent successfully" + end + # call short io api here invitation_url = Rails.application.routes.url_helpers.accept_user_invitation_url(invitation_token: @volunteer.raw_invitation_token, host: request.base_url)