Fix error when model file does not exist

When you have just created a model file using the quick picker/input
box, the data extension editor will try to read it and fail with an
error message. This adds a check to ensure the model file exists and if
it doesn't, it will not try to read in the file.

This should always be safe since the model file picker will only allow
you to select existing files.
This commit is contained in:
Koen Vlaswinkel
2023-04-17 15:40:34 +02:00
parent 0ee090b6e1
commit 3c16b81f25

View File

@@ -18,7 +18,7 @@ import {
showAndLogExceptionWithTelemetry,
} from "../helpers";
import { extLogger } from "../common";
import { outputFile, readFile } from "fs-extra";
import { outputFile, pathExists, readFile } from "fs-extra";
import { load as loadYaml } from "js-yaml";
import { DatabaseItem, DatabaseManager } from "../local-databases";
import { CodeQLCliServer } from "../cli";
@@ -161,6 +161,10 @@ export class DataExtensionsEditorView extends AbstractWebview<
protected async loadExistingModeledMethods(): Promise<void> {
try {
if (!(await pathExists(this.modelFilename))) {
return;
}
const yaml = await readFile(this.modelFilename, "utf8");
const data = loadYaml(yaml, {