Skip to content

Commit

Permalink
Final changes
Browse files Browse the repository at this point in the history
  • Loading branch information
BAntonellini committed May 24, 2024
1 parent 660b08e commit a870fca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/features/helper/dbtInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export enum DbtInterfaceErrorCode {
CompileSqlFailure = 1,
ExecuteSqlFailure = 2,
ProjectParseFailure = 3,
UnlintableUnfixable = 0
}

export interface DbtInterfaceErrorContainer {
Expand Down Expand Up @@ -185,7 +186,6 @@ export class DbtInterface {
abortController.abort();
}, timeout);
let response: Response;

try {
response = await fetch(
encodeURI(this.getFormatURL()),
Expand Down
8 changes: 6 additions & 2 deletions src/features/providers/sqlfluff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default class SQLFluff {

return new Promise<CommandOutput>(async (resolve) => {
const code = response?.error?.code ?? 0;
const succeeded = code === 0;
const succeeded = (code === 0 && !response?.error);
if (!succeeded && !Configuration.suppressNotifications() && !this.shownDbtInterfacePopup) {
const message = response?.error?.message ?? "DBT-Interface formatting error.";
const detail = response?.error?.data?.error ?? "";
Expand All @@ -73,6 +73,8 @@ export default class SQLFluff {
if (chosen === runDbt) {
await vscode.commands.executeCommand("dbtPowerUser.dbtCompile");
}
} else if(code === DbtInterfaceErrorCode.UnlintableUnfixable) {
vscode.window.showErrorMessage("Unable to load SQLFluff due to configuration issue. Try linting an sql file to see more details.")
} else {
vscode.window.showErrorMessage([message, detail].join("\n"));
}
Expand Down Expand Up @@ -146,7 +148,7 @@ export default class SQLFluff {

return new Promise<CommandOutput>(async (resolve) => {
const code = response?.error?.code ?? 0;
const succeeded = code === 0;
const succeeded = (code === 0 && !response?.error);
if (!succeeded && !Configuration.suppressNotifications() && !this.shownDbtInterfacePopup) {
const message = response?.error?.message ?? "DBT-Interface linting error.";
const detail = response?.error?.data?.error ?? "";
Expand All @@ -158,6 +160,8 @@ export default class SQLFluff {
if (chosen === runDbt) {
await vscode.commands.executeCommand("dbtPowerUser.dbtCompile");
}
} else if(code === DbtInterfaceErrorCode.UnlintableUnfixable) {
vscode.window.showErrorMessage("Unable to load SQLFluff due to configuration issue. Try linting an sql file to see more details.")
} else {
vscode.window.showErrorMessage([message, detail].join("\n"));
}
Expand Down

0 comments on commit a870fca

Please sign in to comment.