diff --git a/src/api/build.ts b/src/api/build.ts index ecf5939..f2979ec 100644 --- a/src/api/build.ts +++ b/src/api/build.ts @@ -218,12 +218,12 @@ export async function buildToTinybird( ); } - // Helper to format errors + // Helper to format errors - always returns a meaningful string const formatErrors = (): string => { if (body.errors && body.errors.length > 0) { return body.errors.map(e => { const prefix = e.filename ? `[${e.filename}] ` : ''; - return `${prefix}${e.error}`; + return `${prefix}${e.error ?? 'Unknown error'}`; }).join('\n'); } return body.error || `HTTP ${response.status}: ${response.statusText}`; diff --git a/src/cli/index.ts b/src/cli/index.ts index 368fef8..191b444 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -539,8 +539,9 @@ function createCli(): Command { // Show detailed errors if available if (deploy?.errors && deploy.errors.length > 0) { output.showBuildErrors(deploy.errors); - } else if (result.error) { - output.error(result.error); + } else { + const errorMessage = result.error ?? deploy?.error; + output.error(errorMessage ?? "Deploy failed (run with TINYBIRD_DEBUG=1 for more info)"); } output.showDeployFailure(); process.exit(1); @@ -730,8 +731,9 @@ function createCli(): Command { const { deploy } = result; if (deploy?.errors && deploy.errors.length > 0) { output.showBuildErrors(deploy.errors); - } else if (result.error) { - output.error(result.error); + } else { + const errorMessage = result.error ?? deploy?.error; + output.error(errorMessage ?? "Build failed (run with TINYBIRD_DEBUG=1 for more info)"); } output.showBuildFailure(true); return;