Skip to content

Commit f012ee5

Browse files
Show a more actionable error message when deployment fails (#1050)
## Changes * We were not catching bundle deployment errors because the process was throwing string errors and we don't capture errors which are not instance of `Error` class in onError. * Now, we show that the deployment has failed and ask the user to if they want to see the logs. ## Tests <!-- How is this tested? -->
1 parent 26e03ad commit f012ee5

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

packages/databricks-vscode/src/cli/CliWrapper.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ export interface ConfigEntry {
3535
}
3636

3737
export type SyncType = "full" | "incremental";
38+
export class ProcessError extends Error {
39+
constructor(
40+
message: string,
41+
public code: number | null
42+
) {
43+
super(message);
44+
}
45+
}
3846

3947
async function waitForProcess(
4048
p: ChildProcessWithoutNullStreams,
@@ -63,7 +71,7 @@ async function waitForProcess(
6371
if (code === 0) {
6472
resolve(output.join(""));
6573
} else {
66-
reject(stderr.join(""));
74+
reject(new ProcessError(stderr.join("\n"), code));
6775
}
6876
});
6977
p.on("error", reject);

packages/databricks-vscode/src/ui/bundle-resource-explorer/BundleCommands.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,18 @@ export class BundleCommands implements Disposable {
8484
await this.refreshRemoteState();
8585
}
8686

87-
@onError({popup: {prefix: "Error deploying the bundle."}})
8887
async deployCommand() {
89-
await this.deploy();
88+
try {
89+
await this.deploy();
90+
} catch (e) {
91+
const choice = await window.showErrorMessage(
92+
"Databricks: Error deploying resource.",
93+
"Show Logs"
94+
);
95+
if (choice === "Show Logs") {
96+
this.outputChannel.show();
97+
}
98+
}
9099
}
91100

92101
@onError({popup: {prefix: "Error running resource."}})

0 commit comments

Comments
 (0)