diff options
-rw-r--r-- | packages/astro/src/assets/fonts/utils.ts | 12 | ||||
-rw-r--r-- | packages/astro/src/core/errors/errors-data.ts | 3 |
2 files changed, 12 insertions, 3 deletions
diff --git a/packages/astro/src/assets/fonts/utils.ts b/packages/astro/src/assets/fonts/utils.ts index a5e2f0b9f..1803ecc8b 100644 --- a/packages/astro/src/assets/fonts/utils.ts +++ b/packages/astro/src/assets/fonts/utils.ts @@ -57,9 +57,15 @@ export function extractFontType(str: string): FontType { // Extname includes a leading dot const extension = extname(str).slice(1); if (!isFontType(extension)) { - throw new AstroError(AstroErrorData.CannotExtractFontType, { - cause: `Unexpected extension, got "${extension}"`, - }); + throw new AstroError( + { + ...AstroErrorData.CannotExtractFontType, + message: AstroErrorData.CannotExtractFontType.message(str), + }, + { + cause: `Unexpected extension, got "${extension}"`, + }, + ); } return extension; } diff --git a/packages/astro/src/core/errors/errors-data.ts b/packages/astro/src/core/errors/errors-data.ts index 9e8366dbf..a6a4c174a 100644 --- a/packages/astro/src/core/errors/errors-data.ts +++ b/packages/astro/src/core/errors/errors-data.ts @@ -1297,10 +1297,13 @@ export const UnknownFilesystemError = { * @docs * @description * Cannot extract the font type from the given URL. + * @message + * An error occured while trying to extract the font type from the given URL. */ export const CannotExtractFontType = { name: 'CannotExtractFontType', title: 'Cannot extract the font type from the given URL.', + message: (url: string) => `An error occurred while trying to extract the font type from ${url}`, hint: 'Open an issue at https://github.com/withastro/astro/issues.', } satisfies ErrorData; |