diff --git a/cli/metadata.ts b/cli/metadata.ts index d547cee29f..1591bedba6 100644 --- a/cli/metadata.ts +++ b/cli/metadata.ts @@ -49,6 +49,13 @@ import { FlowFile, replaceInlineScripts } from "./flow.ts"; import { getIsWin } from "./main.ts"; import { FlowValue } from "./gen/types.gen.ts"; +export class LockfileGenerationError extends Error { + constructor(message: string) { + super(message); + this.name = 'LockfileGenerationError'; + } +} + export async function generateAllMetadata() { } function findClosestRawReqs( @@ -376,9 +383,16 @@ async function updateScriptLock( const response = JSON.parse(responseText); const lock = response.lock; if (lock === undefined) { - throw new Error( - `Failed to generate lockfile. Full response was: ${JSON.stringify( - response + if (response?.["error"]?.["message"]) { + throw new LockfileGenerationError( + `Failed to generate lockfile: ${response?.["error"]?.["message"]}` + ); + } + throw new LockfileGenerationError( + `Failed to generate lockfile: ${JSON.stringify( + response, + null, + 2 )}` ); } @@ -395,8 +409,11 @@ async function updateScriptLock( metadataContent.lock = ""; } } catch (e) { - throw new Error( - `Failed to generate lockfile. Status was: ${rawResponse.statusText}, ${responseText}, ${e}` + if (e instanceof LockfileGenerationError) { + throw e; + } + throw new LockfileGenerationError( + `Failed to generate lockfile:${rawResponse.statusText}, ${responseText}, ${e}` ); } } diff --git a/cli/script.ts b/cli/script.ts index 6ab67212e8..37ae635380 100644 --- a/cli/script.ts +++ b/cli/script.ts @@ -990,7 +990,7 @@ const command = new Command() .action(bootstrap as any) .command( "generate-metadata", - "re-generate the metadata file updating the lock and the script schema (for flows, use `wmill flow generate - locks`)" + "re-generate the metadata file updating the lock and the script schema (for flows, use `wmill flow generate-locks`)" ) .arguments("[script:file]") .option("--yes", "Skip confirmation prompt")