forked from FoundKeyGang/FoundKey
client: replace error UUIDs with error codes
The error UUIDs were removed from the backend and trying to match against the IDs no longer works. This can produce confusing UI behaviour when displaying errors. closes FoundKeyGang/FoundKey#363 Changelog: Fixed
This commit is contained in:
parent
bc51450fea
commit
77602203b2
6 changed files with 15 additions and 15 deletions
|
@ -78,7 +78,7 @@ function fetchAccount(token: string): Promise<Account> {
|
|||
api('i', {}, token)
|
||||
.then(res => {
|
||||
if (res.error) {
|
||||
if (res.error.id === 'a8c724b3-6e9c-4b46-b1a8-bc3ed6258370') {
|
||||
if (res.error.code === 'SUSPENDED') {
|
||||
showSuspendedDialog().then(() => {
|
||||
signout();
|
||||
});
|
||||
|
|
|
@ -207,8 +207,8 @@ function deleteFolder() {
|
|||
defaultStore.set('uploadFolder', null);
|
||||
}
|
||||
}).catch(err => {
|
||||
switch (err.id) {
|
||||
case 'b0fc8a17-963c-405d-bfbc-859a487295e1':
|
||||
switch (err.code) {
|
||||
case 'HAS_CHILD_FILES_OR_FOLDERS':
|
||||
os.alert({
|
||||
type: 'error',
|
||||
title: i18n.ts.unableToDelete,
|
||||
|
|
|
@ -258,8 +258,8 @@ function onDrop(ev: DragEvent): any {
|
|||
folderId: droppedFolder.id,
|
||||
parentId: folder?.id ?? null,
|
||||
}).catch(err => {
|
||||
switch (err) {
|
||||
case 'detected-circular-definition':
|
||||
switch (err.code) {
|
||||
case 'RECURSIVE_FOLDER':
|
||||
os.alert({
|
||||
title: i18n.ts.unableToProcess,
|
||||
text: i18n.ts.circularReferenceFolder,
|
||||
|
@ -335,8 +335,8 @@ function deleteFolder(folderToDelete: foundkey.entities.DriveFolder) {
|
|||
// 削除時に親フォルダに移動
|
||||
move(folderToDelete.parentId);
|
||||
}).catch(err => {
|
||||
switch (err.id) {
|
||||
case 'b0fc8a17-963c-405d-bfbc-859a487295e1':
|
||||
switch (err.code) {
|
||||
case 'HAS_CHILD_FILES_OR_FOLDERS':
|
||||
os.alert({
|
||||
type: 'error',
|
||||
title: i18n.ts.unableToDelete,
|
||||
|
|
|
@ -185,8 +185,8 @@ function onSubmit() {
|
|||
}
|
||||
|
||||
function loginFailed(err) {
|
||||
switch (err.id) {
|
||||
case '6cc579cc-885d-43d8-95c2-b8c7fc963280': {
|
||||
switch (err.code) {
|
||||
case 'NO_SUCH_USER': {
|
||||
os.alert({
|
||||
type: 'error',
|
||||
title: i18n.ts.loginFailed,
|
||||
|
@ -194,7 +194,7 @@ function loginFailed(err) {
|
|||
});
|
||||
break;
|
||||
}
|
||||
case '932c904e-9460-45b7-9ce6-7ed33be7eb2c': {
|
||||
case 'ACCESS_DENIED': {
|
||||
os.alert({
|
||||
type: 'error',
|
||||
title: i18n.ts.loginFailed,
|
||||
|
@ -202,11 +202,11 @@ function loginFailed(err) {
|
|||
});
|
||||
break;
|
||||
}
|
||||
case 'e03a5f46-d309-4865-9b69-56282d94e1eb': {
|
||||
case 'SUSPENDED': {
|
||||
showSuspendedDialog();
|
||||
break;
|
||||
}
|
||||
case '22d05606-fbcf-421a-a2db-b32610dcfd1b': {
|
||||
case 'RATE_LIMIT_EXCEEDED': {
|
||||
os.alert({
|
||||
type: 'error',
|
||||
title: i18n.ts.loginFailed,
|
||||
|
|
|
@ -115,7 +115,7 @@ function save() {
|
|||
const options = getSaveOptions();
|
||||
|
||||
const onError = err => {
|
||||
if (err.id === '3d81ceae-475f-4600-b2a8-2bc116157532') {
|
||||
if (err.code === 'INVALID_PARAM') {
|
||||
if (err.info.param === 'name') {
|
||||
os.alert({
|
||||
type: 'error',
|
||||
|
|
|
@ -104,7 +104,7 @@ export function getNoteMenu(props: {
|
|||
os.apiWithDialog(pin ? 'i/pin' : 'i/unpin', {
|
||||
noteId: appearNote.id,
|
||||
}, undefined, null, res => {
|
||||
if (res.id === '72dab508-c64d-498f-8740-a8eec1ba385a') {
|
||||
if (res.code === 'PIN_LIMIT_EXCEEDED') {
|
||||
os.alert({
|
||||
type: 'error',
|
||||
text: i18n.ts.pinLimitExceeded,
|
||||
|
@ -149,7 +149,7 @@ export function getNoteMenu(props: {
|
|||
os.api('clips/add-note', { clipId: clip.id, noteId: appearNote.id }),
|
||||
null,
|
||||
async (err) => {
|
||||
if (err.id === '734806c4-542c-463a-9311-15c512803965') {
|
||||
if (err.id === 'ALREADY_CLIPPED') {
|
||||
const confirm = await os.confirm({
|
||||
type: 'warning',
|
||||
text: i18n.t('confirmToUnclipAlreadyClippedNote', { name: clip.name }),
|
||||
|
|
Loading…
Reference in a new issue