Skip to content

Commit

Permalink
fix: More details for parsing errors during dashboard creation
Browse files Browse the repository at this point in the history
  • Loading branch information
paveltiunov committed Jan 3, 2020
1 parent 7a7a3d2 commit a8cb9d3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
16 changes: 10 additions & 6 deletions packages/cubejs-server-core/dev/templates/SourceSnippet.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ class SourceSnippet {
}

static parse(source) {
return parse(source, {
sourceType: 'module',
plugins: [
"jsx"
]
});
try {
return parse(source, {
sourceType: 'module',
plugins: [
"jsx"
]
});
} catch (e) {
throw new Error(`Can't parse source snippet: ${e.message}\n${source}`);
}
}

mergeImport(targetSource, importDeclaration) {
Expand Down
18 changes: 11 additions & 7 deletions packages/cubejs-server-core/dev/templates/TargetSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ class TargetSource {
constructor(fileName, source) {
this.source = source;
this.fileName = fileName;
this.ast = parse(source, {
sourceFilename: fileName,
sourceType: 'module',
plugins: [
"jsx"
]
});
try {
this.ast = parse(source, {
sourceFilename: fileName,
sourceType: 'module',
plugins: [
"jsx"
]
});
} catch (e) {
throw new Error(`Can't parse ${fileName}: ${e.message}`);
}
this.findAllImports();
this.findAllDefinitions();
this.findDefaultExport();
Expand Down

0 comments on commit a8cb9d3

Please sign in to comment.