Refactor: Simplify error handling in CLI helpers

This commit is contained in:
Aman Varshney
2025-04-28 04:14:23 +05:30
parent a735bd1769
commit aef7aa428a
11 changed files with 10 additions and 25 deletions

View File

@@ -29,7 +29,6 @@ async function executeNeonCommand(
if (s) s.start(spinnerText);
const result = await execa(fullCommand, { shell: true });
if (s) s.stop(spinnerText);
return result;
} catch (error) {
if (s) s.stop(pc.red(`Failed: ${spinnerText}`));
@@ -61,14 +60,13 @@ async function authenticateWithNeon(packageManager: ProjectPackageManager) {
return true;
} catch (error) {
consola.error(pc.red("Failed to authenticate with Neon"));
throw error;
}
}
async function createNeonProject(
projectName: string,
packageManager: ProjectPackageManager,
): Promise<NeonConfig | null> {
) {
try {
const commandArgsString = `neonctl projects create --name "${projectName}" --output json`;
const { stdout } = await executeNeonCommand(
@@ -101,7 +99,6 @@ async function createNeonProject(
return null;
} catch (error) {
consola.error(pc.red("Failed to create Neon project"));
throw error;
}
}