Skip to content

Commit 9333f36

Browse files
Fix @typescript-eslint/prefer-promise-reject-errors by using asError
1 parent 6e1da50 commit 9333f36

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

extensions/ql-vscode/src/codeql-cli/cli.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import type { CliConfig } from "../config";
1919
import type { DistributionProvider } from "./distribution";
2020
import { FindDistributionResultKind } from "./distribution";
2121
import {
22+
asError,
2223
assertNever,
2324
getErrorMessage,
2425
getErrorStack,
@@ -851,7 +852,7 @@ export class CodeQLCliServer implements Disposable {
851852
silent,
852853
).then(resolve, reject);
853854
} catch (err) {
854-
reject(err);
855+
reject(asError(err));
855856
}
856857
};
857858
// If the server is not running a command, then run the given command immediately,

extensions/ql-vscode/src/common/jsonl-reader.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { stat } from "fs/promises";
22
import { createReadStream } from "fs-extra";
33
import type { BaseLogger } from "./logging";
4+
import { asError } from "./helpers-pure";
45

56
const doubleLineBreakRegexp = /\n\r?\n/;
67

@@ -41,7 +42,7 @@ export async function readJsonlFile<T>(
4142
stream.resume();
4243
} catch (e) {
4344
stream.destroy();
44-
reject(e);
45+
reject(asError(e));
4546
}
4647
}
4748
});
@@ -53,7 +54,7 @@ export async function readJsonlFile<T>(
5354
void logger?.log(`Finished parsing ${path}`);
5455
resolve();
5556
} catch (e) {
56-
reject(e);
57+
reject(asError(e));
5758
}
5859
});
5960
stream.on("error", reject);

extensions/ql-vscode/src/common/unzip.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Transform } from "stream";
55
import { dirname, join } from "path";
66
import type { WriteStream } from "fs";
77
import { createWriteStream, ensureDir } from "fs-extra";
8+
import { asError } from "./helpers-pure";
89

910
// We can't use promisify because it picks up the wrong overload.
1011
export function openZip(
@@ -47,7 +48,7 @@ export function readZipEntries(zipFile: ZipFile): Promise<ZipEntry[]> {
4748
});
4849

4950
zipFile.on("error", (err) => {
50-
reject(err);
51+
reject(asError(err));
5152
});
5253
});
5354
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import {
4242
AUTOFIX_PATH,
4343
AUTOFIX_MODEL,
4444
} from "../config";
45-
import { getErrorMessage } from "../common/helpers-pure";
45+
import { asError, getErrorMessage } from "../common/helpers-pure";
4646
import { createTimeoutSignal } from "../common/fetch-stream";
4747
import { unzipToDirectoryConcurrently } from "../common/unzip-concurrently";
4848
import { reportUnzipProgress } from "../common/vscode/unzip-progress";
@@ -819,7 +819,7 @@ function execAutofix(
819819
}
820820
});
821821
} catch (e) {
822-
reject(e);
822+
reject(asError(e));
823823
}
824824
});
825825
}

0 commit comments

Comments
 (0)