Skip to content

Commit

Permalink
Added volunteer invitation error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
7riumph committed Feb 26, 2025
1 parent 6ca5e7f commit 5543b05
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/controllers/volunteers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 5543b05

Please sign in to comment.