Skip to content

Commit 61d7b05

Browse files
committed
Improve error handling
1 parent af47689 commit 61d7b05

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/setup-rdflint.ts

+14-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,21 @@ async function getLatestRdflintVersion(): Promise<string> {
88
const response = await fetch(
99
'https://jitpack.io/api/builds/com.github.imas/rdflint/latestOk'
1010
);
11+
12+
if (!response.ok) {
13+
throw new Error(
14+
`Failed to get the latest rdflint version: ${response.status} ${response.statusText}`
15+
);
16+
}
17+
1118
const { version } = await response.json();
1219

1320
if (typeof version !== 'string') {
14-
throw new Error('Failed to get the latest rdflint version');
21+
throw new Error(
22+
'Failed to get the latest rdflint version: Unexpected version format'
23+
);
1524
}
25+
1626
return version;
1727
}
1828

@@ -27,11 +37,10 @@ async function installRdflint(version: string): Promise<string> {
2737
version
2838
);
2939

40+
const jarPath = path.join(cachePath, 'rdflint.jar');
3041
const executablePath = path.join(cachePath, 'rdflint');
31-
fs.writeFileSync(
32-
executablePath,
33-
`#!/bin/sh\njava -jar ${cachePath}/rdflint.jar $@`
34-
);
42+
43+
fs.writeFileSync(executablePath, `#!/bin/sh\njava -jar ${jarPath} $@`);
3544
fs.chmodSync(executablePath, 0o555);
3645

3746
return cachePath;

0 commit comments

Comments
 (0)