Skip to content

Commit a8cb9d3

Browse files
committed
fix: More details for parsing errors during dashboard creation
1 parent 7a7a3d2 commit a8cb9d3

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

packages/cubejs-server-core/dev/templates/SourceSnippet.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@ class SourceSnippet {
2525
}
2626

2727
static parse(source) {
28-
return parse(source, {
29-
sourceType: 'module',
30-
plugins: [
31-
"jsx"
32-
]
33-
});
28+
try {
29+
return parse(source, {
30+
sourceType: 'module',
31+
plugins: [
32+
"jsx"
33+
]
34+
});
35+
} catch (e) {
36+
throw new Error(`Can't parse source snippet: ${e.message}\n${source}`);
37+
}
3438
}
3539

3640
mergeImport(targetSource, importDeclaration) {

packages/cubejs-server-core/dev/templates/TargetSource.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ class TargetSource {
1010
constructor(fileName, source) {
1111
this.source = source;
1212
this.fileName = fileName;
13-
this.ast = parse(source, {
14-
sourceFilename: fileName,
15-
sourceType: 'module',
16-
plugins: [
17-
"jsx"
18-
]
19-
});
13+
try {
14+
this.ast = parse(source, {
15+
sourceFilename: fileName,
16+
sourceType: 'module',
17+
plugins: [
18+
"jsx"
19+
]
20+
});
21+
} catch (e) {
22+
throw new Error(`Can't parse ${fileName}: ${e.message}`);
23+
}
2024
this.findAllImports();
2125
this.findAllDefinitions();
2226
this.findDefaultExport();

0 commit comments

Comments
 (0)