Skip to content

Commit 7bea39e

Browse files
committed
core: fix domjudge status include 204
1 parent ecac864 commit 7bea39e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/server/service/fetcher.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ const fetch = (url: string, type: 'get' | 'post' = 'get') => {
1515
get(target, prop) {
1616
if (prop === 'then') {
1717
return (...args) => target.then((res) => {
18-
if (res.status !== 200) throw new Error(`Failed to ${type} ${endpoint} : ${res.status} - ${JSON.stringify(res.body || {})}`);
18+
if (![200, 204].includes(res.status)) {
19+
logger.error(`Failed to ${type} ${url} : ${res.status} - ${JSON.stringify(res.body || {})}`);
20+
throw new Error(`Failed to ${type} ${endpoint} : ${res.status} - ${JSON.stringify(res.body || {})}`);
21+
}
1922
return res;
2023
}).then(...args);
2124
}

0 commit comments

Comments
 (0)