Show the actual error when there was an error while generating types (#6762)
This commit is contained in:
parent
b96a129581
commit
8b88e4cf15
3 changed files with 16 additions and 3 deletions
5
.changeset/metal-lizards-arrive.md
Normal file
5
.changeset/metal-lizards-arrive.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Improved error message when an error was encountered while generating types
|
|
@ -828,7 +828,8 @@ See https://docs.astro.build/en/guides/server-side-rendering/ for more informati
|
||||||
GenerateContentTypesError: {
|
GenerateContentTypesError: {
|
||||||
title: 'Failed to generate content types.',
|
title: 'Failed to generate content types.',
|
||||||
code: 8001,
|
code: 8001,
|
||||||
message: '`astro sync` command failed to generate content collection types.',
|
message: (errorMessage: string) =>
|
||||||
|
`\`astro sync\` command failed to generate content collection types: ${errorMessage}`,
|
||||||
hint: 'Check your `src/content/config.*` file for typos.',
|
hint: 'Check your `src/content/config.*` file for typos.',
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { runHookConfigSetup } from '../../integrations/index.js';
|
||||||
import { setUpEnvTs } from '../../vite-plugin-inject-env-ts/index.js';
|
import { setUpEnvTs } from '../../vite-plugin-inject-env-ts/index.js';
|
||||||
import { getTimeStat } from '../build/util.js';
|
import { getTimeStat } from '../build/util.js';
|
||||||
import { createVite } from '../create-vite.js';
|
import { createVite } from '../create-vite.js';
|
||||||
import { AstroError, AstroErrorData } from '../errors/index.js';
|
import { AstroError, AstroErrorData, createSafeError } from '../errors/index.js';
|
||||||
import { info, type LogOptions } from '../logger/core.js';
|
import { info, type LogOptions } from '../logger/core.js';
|
||||||
import { printHelp } from '../messages.js';
|
import { printHelp } from '../messages.js';
|
||||||
|
|
||||||
|
@ -98,7 +98,14 @@ export async function sync(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new AstroError(AstroErrorData.GenerateContentTypesError);
|
const safeError = createSafeError(e);
|
||||||
|
throw new AstroError(
|
||||||
|
{
|
||||||
|
...AstroErrorData.GenerateContentTypesError,
|
||||||
|
message: AstroErrorData.GenerateContentTypesError.message(safeError.message),
|
||||||
|
},
|
||||||
|
{ cause: e }
|
||||||
|
);
|
||||||
} finally {
|
} finally {
|
||||||
await tempViteServer.close();
|
await tempViteServer.close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue