Skip to content

Commit 2c52c1b

Browse files
authored
Improve the error message on code snippet and user defined template (#83)
1 parent f2bc791 commit 2c52c1b

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
"name": "vscode-dtdl",
33
"displayName": "DTDL",
44
"description": "This extension provides syntax highlighting to read and edit JSON documents using the Digital Twins Definition Language",
5-
"version": "0.2.0",
5+
"version": "1.0.0-rc3",
66
"publisher": "vsciot-vscode",
7-
"preview": true,
87
"aiKey": "[AIKEY PLACEHOLDER]",
98
"icon": "logo.png",
109
"license": "SEE LICENSE IN LICENSE.txt",
@@ -95,7 +94,7 @@
9594
"copy-webpack-plugin": "^6.0.1"
9695
},
9796
"dependencies": {
98-
"dtdl-language-server": "^0.4.2",
97+
"dtdl-language-server": "^0.4.3",
9998
"fs-extra": "^7.0.1",
10099
"vscode-extension-telemetry": "^0.1.6",
101100
"vscode-languageclient": "^6.1.3"

snippets/snippets.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"Add DTDL Command" : {
1717
"prefix": "dtc",
1818
"body" : [
19-
"{\n\t\"@type\": \"Command\",\n\t\"name\": \"$1\",\n\t\"schema\": $2\n}"
19+
"{\n\t\"@type\": \"Command\",\n\t\"name\": \"$1\"\n}"
2020
],
2121
"description": "Adds a DTDL Command"
2222
}

src/view/ui.ts

+4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ export class UI {
8585
*/
8686
public static async selectTemplateFile(label: string, folder: string): Promise<string> {
8787
const files: string[] = Utility.listFile(folder, Constants.TEMPLATE_FILE_GLOB);
88+
if (!files.length) {
89+
const message = `${UIConstants.TEMPLATES_NOT_FOUND_MSG} ${folder}`;
90+
throw new Error(message);
91+
}
8892
if (files.length === 1) {
8993
return files[0];
9094
}

src/view/uiConstants.ts

+1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ export class UIConstants {
99
public static readonly SELECT_TEMPLATE_FILE_LABEL = "Select template file";
1010
public static readonly INPUT_MODEL_NAME_LABEL = "Input device model name";
1111
public static readonly BROWSE_LABEL = "Browse...";
12+
public static readonly TEMPLATES_NOT_FOUND_MSG = "No template is found in folder";
1213
}

0 commit comments

Comments
 (0)