File tree Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import type { Context } from "../context"
4
4
import { convertSvelteRoot } from "./converts/index"
5
5
import { sort } from "./sort"
6
6
import type { SvelteProgram } from "../ast"
7
+ import { ParseError } from ".."
7
8
8
9
/**
9
10
* Parse for template
@@ -16,14 +17,23 @@ export function parseTemplate(
16
17
ast : SvelteProgram
17
18
svelteAst : SvAST . Ast
18
19
} {
19
- const svelteAst = parse ( code , {
20
- filename : parserOptions . filePath ,
21
- } ) as SvAST . Ast
22
- const ast = convertSvelteRoot ( svelteAst , ctx )
23
- sort ( ast . body )
20
+ try {
21
+ const svelteAst = parse ( code , {
22
+ filename : parserOptions . filePath ,
23
+ } ) as SvAST . Ast
24
+ const ast = convertSvelteRoot ( svelteAst , ctx )
25
+ sort ( ast . body )
24
26
25
- return {
26
- ast,
27
- svelteAst,
27
+ return {
28
+ ast,
29
+ svelteAst,
30
+ }
31
+ } catch ( e : any ) {
32
+ if ( typeof e . pos === "number" ) {
33
+ const err = new ParseError ( e . message , e . pos , ctx )
34
+ ; ( err as any ) . svelteCompilerError = e
35
+ throw err
36
+ }
37
+ throw e
28
38
}
29
39
}
You can’t perform that action at this time.
0 commit comments