mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-23 05:56:10 +08:00
refactor: remove pointless rethrows causing loss of original error
This commit is contained in:
parent
fb529ae53b
commit
141a84caa7
1 changed files with 13 additions and 40 deletions
|
@ -89,11 +89,7 @@ export type Layout = {
|
|||
* @throws {Error} If the layout list or layout doesn't exist.
|
||||
*/
|
||||
export async function getLayout(layoutName: string): Promise<Layout> {
|
||||
try {
|
||||
return await cachedFetchJson<Layout>(`/layouts/${layoutName}.json`);
|
||||
} catch (e) {
|
||||
throw new Error(`Layout ${layoutName} JSON fetch failed`);
|
||||
}
|
||||
return await cachedFetchJson<Layout>(`/layouts/${layoutName}.json`);
|
||||
}
|
||||
|
||||
export type Theme = {
|
||||
|
@ -161,14 +157,8 @@ export async function getSortedThemesList(): Promise<Theme[]> {
|
|||
* @returns A promise that resolves to the list of languages.
|
||||
*/
|
||||
export async function getLanguageList(): Promise<string[]> {
|
||||
try {
|
||||
const languageList = await cachedFetchJson<string[]>(
|
||||
"/languages/_list.json"
|
||||
);
|
||||
return languageList;
|
||||
} catch (e) {
|
||||
throw new Error("Language list JSON fetch failed");
|
||||
}
|
||||
const languageList = await cachedFetchJson<string[]>("/languages/_list.json");
|
||||
return languageList;
|
||||
}
|
||||
|
||||
export type LanguageGroup = {
|
||||
|
@ -181,14 +171,10 @@ export type LanguageGroup = {
|
|||
* @returns A promise that resolves to the list of language groups.
|
||||
*/
|
||||
export async function getLanguageGroups(): Promise<LanguageGroup[]> {
|
||||
try {
|
||||
const languageGroupList = await cachedFetchJson<LanguageGroup[]>(
|
||||
"/languages/_groups.json"
|
||||
);
|
||||
return languageGroupList;
|
||||
} catch (e) {
|
||||
throw new Error("Language groups JSON fetch failed");
|
||||
}
|
||||
const languageGroupList = await cachedFetchJson<LanguageGroup[]>(
|
||||
"/languages/_groups.json"
|
||||
);
|
||||
return languageGroupList;
|
||||
}
|
||||
|
||||
export type LanguageObject = {
|
||||
|
@ -211,7 +197,6 @@ let currentLanguage: LanguageObject;
|
|||
* @returns A promise that resolves to the language object.
|
||||
*/
|
||||
export async function getLanguage(lang: string): Promise<LanguageObject> {
|
||||
// try {
|
||||
if (currentLanguage === undefined || currentLanguage.name !== lang) {
|
||||
currentLanguage = await cachedFetchJson<LanguageObject>(
|
||||
`/languages/${lang}.json`
|
||||
|
@ -317,12 +302,8 @@ export type Challenge = {
|
|||
* @returns A promise that resolves to the list of challenges.
|
||||
*/
|
||||
export async function getChallengeList(): Promise<Challenge[]> {
|
||||
try {
|
||||
const data = await cachedFetchJson<Challenge[]>("/challenges/_list.json");
|
||||
return data;
|
||||
} catch (e) {
|
||||
throw new Error("Challenge list JSON fetch failed");
|
||||
}
|
||||
const data = await cachedFetchJson<Challenge[]>("/challenges/_list.json");
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -330,12 +311,8 @@ export async function getChallengeList(): Promise<Challenge[]> {
|
|||
* @returns A promise that resolves to the list of supporters.
|
||||
*/
|
||||
export async function getSupportersList(): Promise<string[]> {
|
||||
try {
|
||||
const data = await cachedFetchJson<string[]>("/about/supporters.json");
|
||||
return data;
|
||||
} catch (e) {
|
||||
throw new Error("Supporters list JSON fetch failed");
|
||||
}
|
||||
const data = await cachedFetchJson<string[]>("/about/supporters.json");
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -343,12 +320,8 @@ export async function getSupportersList(): Promise<string[]> {
|
|||
* @returns A promise that resolves to the list of contributors.
|
||||
*/
|
||||
export async function getContributorsList(): Promise<string[]> {
|
||||
try {
|
||||
const data = await cachedFetchJson<string[]>("/about/contributors.json");
|
||||
return data;
|
||||
} catch (e) {
|
||||
throw new Error("Contributors list JSON fetch failed");
|
||||
}
|
||||
const data = await cachedFetchJson<string[]>("/about/contributors.json");
|
||||
return data;
|
||||
}
|
||||
|
||||
type GithubRelease = {
|
||||
|
|
Loading…
Add table
Reference in a new issue