Avoid using exception but simply errors attribute contained in object

Co-Authored-By: Maikel <maikel@email.org.au>
This commit is contained in:
Jean-Baptiste Bellet
2023-03-14 15:56:16 +01:00
parent 8dffb38bf5
commit 29cdadd563

View File

@@ -20,13 +20,12 @@ class InviteManagerReflex < ApplicationReflex
return
end
begin
new_user = create_new_manager(email, enterprise)
new_user = create_new_manager(email, enterprise)
if new_user.errors.empty?
locals[:success] = true
locals[:email] = new_user.email
rescue StandardError => e
@error = e.message
locals[:error] = @error || I18n.t('admin.enterprises.invite_manager.error')
else
locals[:error] = new_user.errors.full_messages.to_sentence
end
return_morph(locals)