From e40311d1145f8ecc015772d3344a6ee6822cf749 Mon Sep 17 00:00:00 2001 From: ernstmul Date: Wed, 29 Jan 2025 12:43:00 +0100 Subject: [PATCH] Add to error handling --- .../onboarding/create-project/+page.svelte | 61 +++++++++++-------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/src/routes/(console)/onboarding/create-project/+page.svelte b/src/routes/(console)/onboarding/create-project/+page.svelte index 63f6318b3..c8c376ce2 100644 --- a/src/routes/(console)/onboarding/create-project/+page.svelte +++ b/src/routes/(console)/onboarding/create-project/+page.svelte @@ -39,36 +39,45 @@ async function createProject() { isLoading = true; - const org = await sdk.forConsole.billing.createOrganization( - ID.unique(), - 'Personal projects', - BillingPlan.FREE, - null, - null - ); - - const teamId = org.$id; + let org; try { - const project = await sdk.forConsole.projects.create( - id ?? ID.unique(), - projectName, - teamId, - Region.Default + org = await sdk.forConsole.billing.createOrganization( + ID.unique(), + 'Personal projects', + BillingPlan.FREE, + null, + null ); - trackEvent(Submit.ProjectCreate, { - customId: !!id, - teamId - }); - - startAnimation = true; - - setTimeout(() => { - goto(`${base}/project-${project.$id}`); - }, 3000); } catch (e) { - // error = e.message; - trackError(e, Submit.ProjectCreate); isLoading = false; + trackError(e, Submit.OrganizationCreate); + throw new Error(e.message); + } + + if (org) { + const teamId = org.$id; + try { + const project = await sdk.forConsole.projects.create( + id ?? ID.unique(), + projectName, + teamId, + Region.Default + ); + trackEvent(Submit.ProjectCreate, { + customId: !!id, + teamId + }); + + startAnimation = true; + + setTimeout(() => { + goto(`${base}/project-${project.$id}`); + }, 3000); + } catch (e) { + trackError(e, Submit.ProjectCreate); + isLoading = false; + throw new Error(e.message); + } } }