Skip to content

Commit

Permalink
Show a more actionable error message when deployment fails (#1050)
Browse files Browse the repository at this point in the history
## 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? -->
  • Loading branch information
kartikgupta-db authored Feb 7, 2024
1 parent 26e03ad commit f012ee5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
10 changes: 9 additions & 1 deletion packages/databricks-vscode/src/cli/CliWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ export interface ConfigEntry {
}

export type SyncType = "full" | "incremental";
export class ProcessError extends Error {
constructor(
message: string,
public code: number | null
) {
super(message);
}
}

async function waitForProcess(
p: ChildProcessWithoutNullStreams,
Expand Down Expand Up @@ -63,7 +71,7 @@ async function waitForProcess(
if (code === 0) {
resolve(output.join(""));
} else {
reject(stderr.join(""));
reject(new ProcessError(stderr.join("\n"), code));
}
});
p.on("error", reject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,18 @@ export class BundleCommands implements Disposable {
await this.refreshRemoteState();
}

@onError({popup: {prefix: "Error deploying the bundle."}})
async deployCommand() {
await this.deploy();
try {
await this.deploy();
} catch (e) {
const choice = await window.showErrorMessage(
"Databricks: Error deploying resource.",
"Show Logs"
);
if (choice === "Show Logs") {
this.outputChannel.show();
}
}
}

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

0 comments on commit f012ee5

Please sign in to comment.