diff --git a/packages/features/team-accounts/src/components/create-team-account-dialog.tsx b/packages/features/team-accounts/src/components/create-team-account-dialog.tsx index 2ce6a3008..0df61e8b0 100644 --- a/packages/features/team-accounts/src/components/create-team-account-dialog.tsx +++ b/packages/features/team-accounts/src/components/create-team-account-dialog.tsx @@ -76,9 +76,9 @@ function CreateOrganizationAccountForm(props: { onClose: () => void }) { data-test={'create-team-form'} onSubmit={form.handleSubmit((data) => { startTransition(async () => { - try { - await createTeamAccountAction(data); - } catch { + const { error } = await createTeamAccountAction(data); + + if (error) { setError(true); } }); diff --git a/packages/features/team-accounts/src/server/actions/create-team-account-server-actions.ts b/packages/features/team-accounts/src/server/actions/create-team-account-server-actions.ts index 64d85a237..a741c2049 100644 --- a/packages/features/team-accounts/src/server/actions/create-team-account-server-actions.ts +++ b/packages/features/team-accounts/src/server/actions/create-team-account-server-actions.ts @@ -31,7 +31,9 @@ export const createTeamAccountAction = enhanceAction( if (error) { logger.error({ ...ctx, error }, `Failed to create team account`); - throw new Error('Error creating team account'); + return { + error: true, + }; } logger.info(ctx, `Team account created`);