Skip to content

Commit 84ab9ee

Browse files
authored
[FDC init] Handle error of template create (#9119)
* handle error * m
1 parent 0668426 commit 84ab9ee

File tree

1 file changed

+17
-12
lines changed
  • src/init/features/dataconnect

1 file changed

+17
-12
lines changed

src/init/features/dataconnect/sdk.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,23 @@ export async function askQuestions(setup: Setup): Promise<void> {
7575
{ name: "no", value: "no" },
7676
],
7777
});
78-
switch (choice) {
79-
case "react":
80-
await createReactApp(newUniqueId("web-app", listFiles(cwd)));
81-
break;
82-
case "next":
83-
await createNextApp(newUniqueId("web-app", listFiles(cwd)));
84-
break;
85-
case "flutter":
86-
await createFlutterApp(newUniqueId("flutter_app", listFiles(cwd)));
87-
break;
88-
case "no":
89-
break;
78+
try {
79+
switch (choice) {
80+
case "react":
81+
await createReactApp(newUniqueId("web-app", listFiles(cwd)));
82+
break;
83+
case "next":
84+
await createNextApp(newUniqueId("web-app", listFiles(cwd)));
85+
break;
86+
case "flutter":
87+
await createFlutterApp(newUniqueId("flutter_app", listFiles(cwd)));
88+
break;
89+
case "no":
90+
break;
91+
}
92+
} catch (err: unknown) {
93+
// The detailed error message are already piped into stderr. No need to repeat here.
94+
logLabeledError("dataconnect", `Failed to create a ${choice} app template`);
9095
}
9196
}
9297

0 commit comments

Comments
 (0)