enhance(client): 分かりやすいエラーメッセージを表示するように

This commit is contained in:
syuilo 2023-01-14 17:46:45 +09:00
parent 6cb9612943
commit a08369fe36
2 changed files with 10 additions and 1 deletions

View File

@ -932,6 +932,7 @@ assign: "アサイン"
unassign: "アサインを解除"
color: "色"
manageCustomEmojis: "カスタム絵文字の管理"
youCannotCreateAnymore: "これ以上作成することはできません。"
_role:
new: "ロールの作成"

View File

@ -4,6 +4,7 @@ import { Component, markRaw, Ref, ref, defineAsyncComponent } from 'vue';
import { EventEmitter } from 'eventemitter3';
import insertTextAtCursor from 'insert-text-at-cursor';
import * as Misskey from 'misskey-js';
import { i18n } from './i18n';
import MkPostFormDialog from '@/components/MkPostFormDialog.vue';
import MkWaitingDialog from '@/components/MkWaitingDialog.vue';
import { MenuItem } from '@/types/menu';
@ -17,9 +18,16 @@ export const apiWithDialog = ((
) => {
const promise = api(endpoint, data, token);
promiseDialog(promise, null, (err) => {
let title = null;
let text = err.message + '\n' + (err as any).id;
if (err.code.startsWith('TOO_MANY')) {
title = i18n.ts.youCannotCreateAnymore;
text = `${i18n.ts.error}: ${err.id}`;
}
alert({
type: 'error',
text: err.message + '\n' + (err as any).id,
title,
text,
});
});