@@ -5,7 +5,7 @@ import { trimStart, trimEnd } from './utils/trim.js';
5
5
import getCodeFrame from '../utils/getCodeFrame.js' ;
6
6
import hash from './utils/hash.js' ;
7
7
8
- function ParseError ( message , template , index ) {
8
+ function ParseError ( message , template , index , filename ) {
9
9
const { line, column } = locate ( template , index ) ;
10
10
11
11
this . name = 'ParseError' ;
@@ -14,13 +14,14 @@ function ParseError ( message, template, index ) {
14
14
15
15
this . loc = { line : line + 1 , column } ;
16
16
this . pos = index ;
17
+ this . filename = filename ;
17
18
}
18
19
19
20
ParseError . prototype . toString = function ( ) {
20
21
return `${ this . message } (${ this . loc . line } :${ this . loc . column } )\n${ this . frame } ` ;
21
22
} ;
22
23
23
- export default function parse ( template ) {
24
+ export default function parse ( template , options = { } ) {
24
25
if ( typeof template !== 'string' ) {
25
26
throw new TypeError ( 'Template must be a string' ) ;
26
27
}
@@ -41,7 +42,7 @@ export default function parse ( template ) {
41
42
} ,
42
43
43
44
error ( message , index = this . index ) {
44
- throw new ParseError ( message , this . template , index ) ;
45
+ throw new ParseError ( message , this . template , index , options . filename ) ;
45
46
} ,
46
47
47
48
eat ( str , required ) {
0 commit comments