Skip to content

Commit ca71cf3

Browse files
refactor(error): use cause
1 parent 29db378 commit ca71cf3

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/index.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,20 @@ export async function result(
9191
const data = await response.json() as any;
9292
formattedRepository = data.full_name;
9393
}
94-
catch {
94+
catch (error) {
9595
if (!resolveOnNpmRegistry) {
96-
throw new Error("Invalid repository, cannot find it on GitHub");
96+
throw new Error("Invalid repository, cannot find it on GitHub", {
97+
cause: error
98+
});
9799
}
98100

99-
let failed = false;
100-
101101
try {
102102
formattedRepository = await getNpmRepository(repository);
103103
}
104-
catch {
105-
failed = true;
106-
}
107-
108-
if (failed) {
109-
throw new Error("Invalid repository, cannot find it on GitHub or NPM registry");
104+
catch (error) {
105+
throw new Error("Invalid repository, cannot find it on GitHub or NPM registry", {
106+
cause: error
107+
});
110108
}
111109
}
112110

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"compilerOptions": {
33
"declaration": true,
44
"strictNullChecks": true,
5-
"target": "ES2020",
5+
"target": "ES2022",
66
"outDir": "dist",
7-
"module": "ES2020",
7+
"module": "ES2022",
88
"moduleResolution": "node",
99
"esModuleInterop": true,
1010
"resolveJsonModule": true,

0 commit comments

Comments
 (0)