Skip to content

Commit 8fb3100

Browse files
committed
error logs
1 parent a899431 commit 8fb3100

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/lib/kumilinwa/refreshCache.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ import { fileURLToPath } from 'url';
88
const Dirname = join(dirname(fileURLToPath(import.meta.url)));
99

1010
export async function refreshCachedLangSpec() {
11-
const data = await fetch(LangSpecURL).then(res => res.json());
11+
const data = await fetch(LangSpecURL).then(res => {
12+
try {
13+
return res.json();
14+
} catch {
15+
res.text().then(text => {
16+
throw new SyntaxError(`Failed to parse GitHub response body as JSON: ${text}`);
17+
});
18+
}
19+
});
1220
await writeFile(join(Dirname, 'langspec.cache.json'), JSON.stringify(data));
1321
await new Jsoning(join(Dirname, '..', '..', '..', 'stats.tmp.db.json')).set(
1422
'langSpecCacheAge',

0 commit comments

Comments
 (0)