Skip to content

Commit 141a84c

Browse files
committed
refactor: remove pointless rethrows causing loss of original error
1 parent fb529ae commit 141a84c

File tree

1 file changed

+13
-40
lines changed

1 file changed

+13
-40
lines changed

frontend/src/ts/utils/json-data.ts

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,7 @@ export type Layout = {
8989
* @throws {Error} If the layout list or layout doesn't exist.
9090
*/
9191
export async function getLayout(layoutName: string): Promise<Layout> {
92-
try {
93-
return await cachedFetchJson<Layout>(`/layouts/${layoutName}.json`);
94-
} catch (e) {
95-
throw new Error(`Layout ${layoutName} JSON fetch failed`);
96-
}
92+
return await cachedFetchJson<Layout>(`/layouts/${layoutName}.json`);
9793
}
9894

9995
export type Theme = {
@@ -161,14 +157,8 @@ export async function getSortedThemesList(): Promise<Theme[]> {
161157
* @returns A promise that resolves to the list of languages.
162158
*/
163159
export async function getLanguageList(): Promise<string[]> {
164-
try {
165-
const languageList = await cachedFetchJson<string[]>(
166-
"/languages/_list.json"
167-
);
168-
return languageList;
169-
} catch (e) {
170-
throw new Error("Language list JSON fetch failed");
171-
}
160+
const languageList = await cachedFetchJson<string[]>("/languages/_list.json");
161+
return languageList;
172162
}
173163

174164
export type LanguageGroup = {
@@ -181,14 +171,10 @@ export type LanguageGroup = {
181171
* @returns A promise that resolves to the list of language groups.
182172
*/
183173
export async function getLanguageGroups(): Promise<LanguageGroup[]> {
184-
try {
185-
const languageGroupList = await cachedFetchJson<LanguageGroup[]>(
186-
"/languages/_groups.json"
187-
);
188-
return languageGroupList;
189-
} catch (e) {
190-
throw new Error("Language groups JSON fetch failed");
191-
}
174+
const languageGroupList = await cachedFetchJson<LanguageGroup[]>(
175+
"/languages/_groups.json"
176+
);
177+
return languageGroupList;
192178
}
193179

194180
export type LanguageObject = {
@@ -211,7 +197,6 @@ let currentLanguage: LanguageObject;
211197
* @returns A promise that resolves to the language object.
212198
*/
213199
export async function getLanguage(lang: string): Promise<LanguageObject> {
214-
// try {
215200
if (currentLanguage === undefined || currentLanguage.name !== lang) {
216201
currentLanguage = await cachedFetchJson<LanguageObject>(
217202
`/languages/${lang}.json`
@@ -317,38 +302,26 @@ export type Challenge = {
317302
* @returns A promise that resolves to the list of challenges.
318303
*/
319304
export async function getChallengeList(): Promise<Challenge[]> {
320-
try {
321-
const data = await cachedFetchJson<Challenge[]>("/challenges/_list.json");
322-
return data;
323-
} catch (e) {
324-
throw new Error("Challenge list JSON fetch failed");
325-
}
305+
const data = await cachedFetchJson<Challenge[]>("/challenges/_list.json");
306+
return data;
326307
}
327308

328309
/**
329310
* Fetches the list of supporters from the server.
330311
* @returns A promise that resolves to the list of supporters.
331312
*/
332313
export async function getSupportersList(): Promise<string[]> {
333-
try {
334-
const data = await cachedFetchJson<string[]>("/about/supporters.json");
335-
return data;
336-
} catch (e) {
337-
throw new Error("Supporters list JSON fetch failed");
338-
}
314+
const data = await cachedFetchJson<string[]>("/about/supporters.json");
315+
return data;
339316
}
340317

341318
/**
342319
* Fetches the list of contributors from the server.
343320
* @returns A promise that resolves to the list of contributors.
344321
*/
345322
export async function getContributorsList(): Promise<string[]> {
346-
try {
347-
const data = await cachedFetchJson<string[]>("/about/contributors.json");
348-
return data;
349-
} catch (e) {
350-
throw new Error("Contributors list JSON fetch failed");
351-
}
323+
const data = await cachedFetchJson<string[]>("/about/contributors.json");
324+
return data;
352325
}
353326

354327
type GithubRelease = {

0 commit comments

Comments
 (0)