- DB::transaction(function () use ($validated, $sendInvite) {
- $this->userRepo->create($validated, $sendInvite);
- });
+ try {
+ DB::transaction(function () use ($validated, $sendInvite) {
+ $this->userRepo->create($validated, $sendInvite);
+ });
+ } catch (UserInviteException $e) {
+ Log::error("Failed to send user invite with error: {$e->getMessage()}");
+ $this->showErrorNotification(trans('errors.users_could_not_send_invite'));
+ return redirect('/settings/users/create')->withInput();
+ }