Skip to content

Commit d887ca5

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Use 'getErrorMessage' and remove uses of 'console.error'
1 parent bbc7413 commit d887ca5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

extensions/ql-vscode/src/variant-analysis/view-autofixes.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { tryOpenExternalFile } from "../common/vscode/external-files";
2727
import type { VariantAnalysisManager } from "./variant-analysis-manager";
2828
import type { VariantAnalysisResultsManager } from "./variant-analysis-results-manager";
2929
import { getAutofixPath, getAutofixModel } from "../config";
30+
import { getErrorMessage } from "../common/helpers-pure";
3031

3132
// Limit to three repos when generating autofixes so not sending
3233
// too many requests to autofix. Since we only need to validate
@@ -497,8 +498,9 @@ async function downloadPublicCommitSource(
497498

498499
return checkoutDir;
499500
} catch (error) {
500-
const errorMessage = error instanceof Error ? error.message : String(error);
501-
throw new Error(`Failed to download ${nwo} at ${sha}: ${errorMessage}`);
501+
throw new Error(
502+
`Failed to download ${nwo} at ${sha}:. Reason: ${getErrorMessage(error)}`,
503+
);
502504
}
503505
}
504506

@@ -755,8 +757,7 @@ async function mergeFiles(
755757
await Promise.all(inputFiles.map((file) => unlink(file)));
756758
}
757759
} catch (error) {
758-
console.error("Error merging files:", error);
759-
throw error;
760+
throw new Error(`Error merging files. Reason: ${getErrorMessage(error)}`);
760761
}
761762
}
762763

@@ -791,7 +792,6 @@ async function formatWithMarkdown(
791792
// Write the formatted content back to the file
792793
await writeFile(inputFile, formattedContent);
793794
} catch (error) {
794-
console.error("Error formatting file:", error);
795-
throw error;
795+
throw new Error(`Error formatting file. Reason: ${getErrorMessage(error)}`);
796796
}
797797
}

0 commit comments

Comments
 (0)