Skip to content

Commit fe0eca4

Browse files
committed
1
1 parent 98b5848 commit fe0eca4

4 files changed

Lines changed: 13 additions & 9 deletions

File tree

src/public/locales/ru-RU.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5480,7 +5480,7 @@
54805480
"locked": "Не разблокировано",
54815481
"toast_title": "Достижения разблокированы!",
54825482
"error": {
5483-
"load_failed": "Не удалось загрузить достижения: `${message}",
5483+
"load_failed": "Не удалось загрузить достижения: ${message}",
54845484
"unlock_failed": "Не удалось разблокировать достижение: ${error}"
54855485
},
54865486
"achievements": {

src/public/pages/scripts/endpoints/base.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
*/
66
async function parseJsonResponse(response) {
77
if (!response.ok) {
8-
const data = await response.json().catch(() => ({}))
8+
let data = {}
9+
try { data = await response.json() }
10+
catch { /* non-JSON body */ }
911
throw Object.assign(new Error(`API request failed with status ${response.status}`), data, { response })
1012
}
1113
return response.json()
@@ -30,8 +32,7 @@ export async function ping(with_cache = false) {
3032
*/
3133
export async function hosturl_in_local_ip() {
3234
try {
33-
const data = await ping(true)
34-
return data.hosturl_in_local_ip
35+
return (await ping(true)).hosturl_in_local_ip
3536
}
3637
catch {
3738
return window.location.origin
@@ -197,8 +198,7 @@ export async function authenticate() {
197198
*/
198199
export async function getUserSetting(key) {
199200
const response = await fetch(`/api/getusersetting?key=${encodeURIComponent(key)}`)
200-
const { value } = await parseJsonResponse(response)
201-
return value
201+
return (await parseJsonResponse(response)).value
202202
}
203203

204204
/**

src/public/pages/scripts/endpoints/parts.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,9 @@ export async function unlockAchievement(partpath, achievementId) {
206206
body: JSON.stringify({ partpath, id: achievementId }),
207207
})
208208
if (!response.ok) {
209-
const data = await response.json().catch(() => ({}))
209+
let data = {}
210+
try { data = await response.json() }
211+
catch { /* non-JSON body */ }
210212
throw Object.assign(new Error(`API request failed with status ${response.status}`), data, { response })
211213
}
212214
}

src/public/pages/scripts/endpoints/registries.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ export async function getRegistry(name, { nocache = false } = {}) {
2525

2626
if (!nocache) {
2727
registryFetchCache.set(name, fetchPromise)
28-
fetchPromise.catch(() => {
28+
try { await fetchPromise }
29+
catch (error) {
2930
if (registryFetchCache.get(name) === fetchPromise)
3031
registryFetchCache.delete(name)
31-
})
32+
throw error
33+
}
3234
}
3335
return fetchPromise
3436
}

0 commit comments

Comments
 (0)