Skip to content

Commit 93470a1

Browse files
add missing message to a Fonts API error (#13612)
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
1 parent 0e5b4ce commit 93470a1

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

‎packages/astro/src/assets/fonts/utils.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,15 @@ export function extractFontType(str: string): FontType {
5757
// Extname includes a leading dot
5858
const extension = extname(str).slice(1);
5959
if (!isFontType(extension)) {
60-
throw new AstroError(AstroErrorData.CannotExtractFontType, {
61-
cause: `Unexpected extension, got "${extension}"`,
62-
});
60+
throw new AstroError(
61+
{
62+
...AstroErrorData.CannotExtractFontType,
63+
message: AstroErrorData.CannotExtractFontType.message(str),
64+
},
65+
{
66+
cause: `Unexpected extension, got "${extension}"`,
67+
},
68+
);
6369
}
6470
return extension;
6571
}

‎packages/astro/src/core/errors/errors-data.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,10 +1297,13 @@ export const UnknownFilesystemError = {
12971297
* @docs
12981298
* @description
12991299
* Cannot extract the font type from the given URL.
1300+
* @message
1301+
* An error occured while trying to extract the font type from the given URL.
13001302
*/
13011303
export const CannotExtractFontType = {
13021304
name: 'CannotExtractFontType',
13031305
title: 'Cannot extract the font type from the given URL.',
1306+
message: (url: string) => `An error occurred while trying to extract the font type from ${url}`,
13041307
hint: 'Open an issue at https://github.com/withastro/astro/issues.',
13051308
} satisfies ErrorData;
13061309

0 commit comments

Comments
 (0)