Skip to content

Commit 0079bd3

Browse files
committed
improved exception handling in run results
1 parent 1fd470a commit 0079bd3

File tree

5 files changed

+47
-31
lines changed

5 files changed

+47
-31
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"bugs": {
1414
"url": "https://github.com/innoverio/vscode-dbt-power-user/issues"
1515
},
16-
"version": "0.4.7",
16+
"version": "0.4.8",
1717
"engines": {
1818
"vscode": "^1.52.0"
1919
},

src/manifest/parsers/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,14 @@ export class ManifestParser {
5353
macros
5454
);
5555
const sourceMetaMapPromise = this.sourceParser.createSourceMetaMap(sources);
56+
5657
const runResultMetaMapPromise = this.runResultsParser.createRunResultMetaMap(
5758
projectRoot,
58-
targetPath
59+
targetPath,
60+
nodes
5961
);
6062

63+
6164
const [
6265
modelMetaMap,
6366
macroMetaMap,

src/manifest/parsers/runResultsParser.ts

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,53 @@ import { provide } from "inversify-binding-decorators";
33
import * as path from "path";
44
import { Uri } from "vscode";
55
import { RunResultMetaMap } from "../../domain";
6+
import { Reporter } from "../../reporter";
67
import { DBTProject } from "../dbtProject";
78

89
@provide(RunResultsParser)
910
export class RunResultsParser {
10-
createRunResultMetaMap(projectRoot: Uri, targetPath: string): Promise<RunResultMetaMap> {
11+
constructor(private reporter: Reporter) {}
12+
13+
createRunResultMetaMap(
14+
projectRoot: Uri,
15+
targetPath: string,
16+
nodes: any
17+
): Promise<RunResultMetaMap> {
1118
return new Promise((resolve) => {
19+
1220
const runResultMetaMap: RunResultMetaMap = new Map();
13-
const runResultPath = path.join(
14-
projectRoot.fsPath,
15-
targetPath,
16-
DBTProject.RUN_RESULTS_FILE
17-
);
18-
if (!existsSync(runResultPath)) {
19-
resolve(runResultMetaMap);
20-
}
21-
const runResultFile = JSON.parse(readFileSync(runResultPath, "utf8"));
22-
const { results, generated_at } = runResultFile;
23-
results.forEach((result: any) => {
24-
const {
25-
node: { root_path, build_path, original_file_path, compiled },
26-
error,
27-
status,
28-
} = result;
29-
const fullPath = path.join(root_path, original_file_path);
30-
const compiledPath =
31-
build_path !== null ? path.join(root_path, build_path) : undefined;
32-
runResultMetaMap.set(fullPath, {
33-
compiledPath,
34-
error,
35-
timestamp: generated_at,
36-
status,
21+
try {
22+
const runResultPath = path.join(
23+
projectRoot.fsPath,
24+
targetPath,
25+
DBTProject.RUN_RESULTS_FILE
26+
);
27+
if (!existsSync(runResultPath)) {
28+
resolve(runResultMetaMap);
29+
}
30+
const runResultFile = JSON.parse(readFileSync(runResultPath, "utf8"));
31+
const { results, generated_at } = runResultFile;
32+
results.forEach((result: any) => {
33+
const {
34+
node: { root_path, build_path, original_file_path, compiled },
35+
error,
36+
status,
37+
} = result;
38+
const fullPath = path.join(root_path, original_file_path);
39+
const compiledPath =
40+
build_path !== null ? path.join(root_path, build_path) : undefined;
41+
runResultMetaMap.set(fullPath, {
42+
compiledPath,
43+
error,
44+
timestamp: generated_at,
45+
status,
46+
});
3747
});
38-
});
39-
resolve(runResultMetaMap);
48+
resolve(runResultMetaMap);
49+
}catch(error) {
50+
this.reporter.sendException(error);
51+
resolve(runResultMetaMap);
52+
}
4053
});
4154
}
4255
}

src/treeview_provider/ModelTreeviewProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ abstract class ModelTreeviewProvider
6868
return Promise.resolve([]);
6969
}
7070

71-
const currentFilePath = window.activeTextEditor!.document.uri;
71+
const currentFilePath = window.activeTextEditor.document.uri;
7272
const projectRootpath = this.dbtProjectContainer.getProjectRootpath(
7373
currentFilePath
7474
);

0 commit comments

Comments
 (0)