Skip to content

Commit dd08dab

Browse files
improve error message when jar generation fails (#23)
* improve error message when jar generation fails Signed-off-by: Kathryn Kodama <[email protected]>
1 parent 2d81a4f commit dd08dab

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

src/commands/generateProject.ts

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,35 @@ export async function generateProject(clickedFileUri: vscode.Uri | undefined): P
9696
try {
9797
await generateRestClient(jarCommand);
9898
} catch (e) {
99-
if (e.message.includes(SPEC_VALIDATION_EXCEPTION)) {
100-
const selection = await vscode.window.showErrorMessage(
101-
`The provided yaml ${yamlType} failed the OpenAPI specification validation. Would you like to generate without specification validation?`,
102-
...["Yes", "No"]
103-
);
104-
if (selection === "Yes") {
105-
jarCommand += " --skip-validate-spec";
106-
await generateRestClient(jarCommand);
99+
console.error(e);
100+
if (e.message.includes(jarCommand)) {
101+
// get error description returned from executing jar command
102+
let err = e.message.trim().split(jarCommand);
103+
err = err[1].trim().split("\n")[0];
104+
105+
// catch spec validation error
106+
if (err.includes(SPEC_VALIDATION_EXCEPTION)) {
107+
const selection = await vscode.window.showErrorMessage(
108+
`The provided yaml ${yamlType} failed the OpenAPI specification validation. Would you like to generate without specification validation?`,
109+
...["Yes", "No"]
110+
);
111+
if (selection === "Yes") {
112+
jarCommand += " --skip-validate-spec";
113+
await generateRestClient(jarCommand);
114+
} else {
115+
return;
116+
}
107117
} else {
118+
vscode.window.showErrorMessage(
119+
`Failed to generate a MicroProfile Rest Client interface from the provided yaml ${yamlType}: ${err}`
120+
);
108121
return;
109122
}
123+
} else {
124+
vscode.window.showErrorMessage(
125+
"Failed to generate MicroProfile Rest Client interface template."
126+
);
127+
return;
110128
}
111129
}
112130

0 commit comments

Comments
 (0)