Skip to content

Commit 06c94a1

Browse files
gnzjgoampcode-com
andcommitted
fix: show meaningful error messages instead of undefined on build/dev failures (#131)
Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-019d1b0d-6dca-7013-a8f8-af75363aae7d
1 parent 5665c22 commit 06c94a1

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/api/build.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,12 @@ export async function buildToTinybird(
218218
);
219219
}
220220

221-
// Helper to format errors
221+
// Helper to format errors - always returns a meaningful string
222222
const formatErrors = (): string => {
223223
if (body.errors && body.errors.length > 0) {
224224
return body.errors.map(e => {
225225
const prefix = e.filename ? `[${e.filename}] ` : '';
226-
return `${prefix}${e.error}`;
226+
return `${prefix}${e.error ?? 'Unknown error'}`;
227227
}).join('\n');
228228
}
229229
return body.error || `HTTP ${response.status}: ${response.statusText}`;

src/cli/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,9 @@ function createCli(): Command {
539539
// Show detailed errors if available
540540
if (deploy?.errors && deploy.errors.length > 0) {
541541
output.showBuildErrors(deploy.errors);
542-
} else if (result.error) {
543-
output.error(result.error);
542+
} else {
543+
const errorMessage = result.error ?? deploy?.error;
544+
output.error(errorMessage ?? "Deploy failed (run with TINYBIRD_DEBUG=1 for more info)");
544545
}
545546
output.showDeployFailure();
546547
process.exit(1);
@@ -730,8 +731,9 @@ function createCli(): Command {
730731
const { deploy } = result;
731732
if (deploy?.errors && deploy.errors.length > 0) {
732733
output.showBuildErrors(deploy.errors);
733-
} else if (result.error) {
734-
output.error(result.error);
734+
} else {
735+
const errorMessage = result.error ?? deploy?.error;
736+
output.error(errorMessage ?? "Build failed (run with TINYBIRD_DEBUG=1 for more info)");
735737
}
736738
output.showBuildFailure(true);
737739
return;

0 commit comments

Comments
 (0)