修改错误处理方式

This commit is contained in:
lyswhut 2023-09-06 19:57:09 +08:00
parent de15a3b2ae
commit 9eb7d5a4e3
3 changed files with 21 additions and 9 deletions

View File

@ -183,13 +183,13 @@ export const connect = (urlInfo: LX.Sync.UrlInfo, keyInfo: LX.Sync.KeyInfo) => {
},
onError(error, path, groupName) {
const name = groupName ?? ''
log.error(`sync call ${name} ${path.join('.')} error:`, error)
if (groupName == null) return
client?.close(SYNC_CLOSE_CODE.failed)
sendSyncStatus({
status: false,
message: error.message,
})
log.r_error(`sync call ${name} ${path.join('.')} error:`, error)
// if (groupName == null) return
// client?.close(SYNC_CLOSE_CODE.failed)
// sendSyncStatus({
// status: false,
// message: error.message,
// })
},
})

View File

@ -1,3 +1,4 @@
import { SYNC_CLOSE_CODE } from '@/plugins/sync/constants'
import { registerDislikeActionEvent } from '../../../dislikeEvent'
let unregisterLocalListAction: (() => void) | null
@ -11,7 +12,12 @@ export const registerEvent = (socket: LX.Sync.Socket) => {
unregisterEvent()
unregisterLocalListAction = registerDislikeActionEvent((action) => {
if (!socket.moduleReadys?.dislike) return
void socket.remoteQueueDislike.onDislikeSyncAction(action)
void socket.remoteQueueDislike.onDislikeSyncAction(action).catch(err => {
// TODO send status
socket.moduleReadys.dislike = false
socket.close(SYNC_CLOSE_CODE.failed)
console.log(err.message)
})
})
}

View File

@ -1,3 +1,4 @@
import { SYNC_CLOSE_CODE } from '@/plugins/sync/constants'
import { registerListActionEvent } from '../../../listEvent'
let unregisterLocalListAction: (() => void) | null
@ -11,7 +12,12 @@ export const registerEvent = (socket: LX.Sync.Socket) => {
unregisterEvent()
unregisterLocalListAction = registerListActionEvent((action) => {
if (!socket.moduleReadys?.list) return
void socket.remoteQueueList.onListSyncAction(action)
void socket.remoteQueueList.onListSyncAction(action).catch(err => {
// TODO send status
socket.moduleReadys.list = false
socket.close(SYNC_CLOSE_CODE.failed)
console.log(err.message)
})
})
}