@@ -3,6 +3,7 @@ import { fileURLToPath } from 'node:url';
33import yaml from 'js-yaml' ;
44import { posixRelative } from '../utils.js' ;
55import type { Loader , LoaderContext } from './types.js' ;
6+ import { AstroError } from '../../core/errors/index.js' ;
67
78interface FileOptions {
89 /**
@@ -21,8 +22,10 @@ interface FileOptions {
2122 */
2223export function file ( fileName : string , options ?: FileOptions ) : Loader {
2324 if ( fileName . includes ( '*' ) ) {
24- // TODO: AstroError
25- throw new Error ( 'Glob patterns are not supported in `file` loader. Use `glob` loader instead.' ) ;
25+ throw new AstroError ( {
26+ name : 'Glob Pattern Error' ,
27+ message : 'Glob patterns are not supported in `file` loader. Use `glob` loader instead.' ,
28+ } ) ;
2629 }
2730
2831 let parse : ( ( text : string ) => any ) | null = null ;
@@ -39,10 +42,10 @@ export function file(fileName: string, options?: FileOptions): Loader {
3942 if ( options ?. parser ) parse = options . parser ;
4043
4144 if ( parse === null ) {
42- // TODO: AstroError
43- throw new Error (
44- `No parser found for file '${ fileName } '. Try passing a parser to the \`file\` loader.` ,
45- ) ;
45+ throw new AstroError ( {
46+ name : 'Parser Not Found' ,
47+ message : `No parser found for file '${ fileName } '. Try passing a parser to the \`file\` loader.` ,
48+ } ) ;
4649 }
4750
4851 async function syncData ( filePath : string , { logger, parseData, store, config } : LoaderContext ) {
0 commit comments