forked from mirror/misskey
better error handling
This commit is contained in:
parent
02e85ca670
commit
5670b29cfa
@ -51,6 +51,11 @@ watch(name, () => {
|
|||||||
// 空文字列をnullにしたいので??は使うな
|
// 空文字列をnullにしたいので??は使うな
|
||||||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
||||||
name: name.value || null,
|
name: name.value || null,
|
||||||
|
}, undefined, {
|
||||||
|
'SCREEN_NAME_CONTAINS_PROHIBITED_WORDS': {
|
||||||
|
title: i18n.ts.screenNameContainsProhibitedWords,
|
||||||
|
text: i18n.ts.screenNameContainsProhibitedWordsDescription,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ export const apiWithDialog = (<E extends keyof Misskey.Endpoints = keyof Misskey
|
|||||||
endpoint: E,
|
endpoint: E,
|
||||||
data: P = {} as any,
|
data: P = {} as any,
|
||||||
token?: string | null | undefined,
|
token?: string | null | undefined,
|
||||||
|
customErrors?: Record<string, { title?: string; text: string; }>,
|
||||||
) => {
|
) => {
|
||||||
const promise = misskeyApi(endpoint, data, token);
|
const promise = misskeyApi(endpoint, data, token);
|
||||||
promiseDialog(promise, null, async (err) => {
|
promiseDialog(promise, null, async (err) => {
|
||||||
@ -77,9 +78,9 @@ export const apiWithDialog = (<E extends keyof Misskey.Endpoints = keyof Misskey
|
|||||||
} else if (err.message.startsWith('Unexpected token')) {
|
} else if (err.message.startsWith('Unexpected token')) {
|
||||||
title = i18n.ts.gotInvalidResponseError;
|
title = i18n.ts.gotInvalidResponseError;
|
||||||
text = i18n.ts.gotInvalidResponseErrorDescription;
|
text = i18n.ts.gotInvalidResponseErrorDescription;
|
||||||
} else if (err.code === 'SCREEN_NAME_CONTAINS_PROHIBITED_WORDS') {
|
} else if (customErrors && customErrors[err.code] != null) {
|
||||||
title = i18n.ts.screenNameContainsProhibitedWords;
|
title = customErrors[err.code].title;
|
||||||
text = i18n.ts.screenNameContainsProhibitedWordsDescription;
|
text = customErrors[err.code].text;
|
||||||
}
|
}
|
||||||
alert({
|
alert({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
@ -89,7 +90,7 @@ export const apiWithDialog = (<E extends keyof Misskey.Endpoints = keyof Misskey
|
|||||||
});
|
});
|
||||||
|
|
||||||
return promise;
|
return promise;
|
||||||
}) as typeof misskeyApi;
|
});
|
||||||
|
|
||||||
export function promiseDialog<T extends Promise<any>>(
|
export function promiseDialog<T extends Promise<any>>(
|
||||||
promise: T,
|
promise: T,
|
||||||
|
@ -206,6 +206,11 @@ function save() {
|
|||||||
lang: profile.lang || null,
|
lang: profile.lang || null,
|
||||||
isBot: !!profile.isBot,
|
isBot: !!profile.isBot,
|
||||||
isCat: !!profile.isCat,
|
isCat: !!profile.isCat,
|
||||||
|
}, undefined, {
|
||||||
|
'SCREEN_NAME_CONTAINS_PROHIBITED_WORDS': {
|
||||||
|
title: i18n.ts.screenNameContainsProhibitedWords,
|
||||||
|
text: i18n.ts.screenNameContainsProhibitedWordsDescription,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
globalEvents.emit('requestClearPageCache');
|
globalEvents.emit('requestClearPageCache');
|
||||||
claimAchievement('profileFilled');
|
claimAchievement('profileFilled');
|
||||||
|
Loading…
Reference in New Issue
Block a user