refactor(main): ipcSuccess/ipcError 헬퍼 통일 + catch(error) 패턴 (WS-PATTERN)
- cloud-sync-handlers 수동 ok/fail -> ipcSuccess/ipcError 헬퍼 (6 핸들러)
- catch {} -> catch(error) 에러 메시지 보강 32건 (11 ipc handler 파일)
KEEP: template-handlers(주석 명시 에러 무시), license-handlers(이미 헬퍼 사용),
audio-handlers stop().catch(() => {})(의도적 무시)
정책: docs/REFACTOR_POLICY.md DP2
This commit is contained in:
parent
4c256202f7
commit
5b6e7aae6b
11 changed files with 133 additions and 93 deletions
|
|
@ -15,16 +15,18 @@ export function registerHistoryHandlers(): void {
|
|||
ipcMain.handle(IPC_CHANNELS.HISTORY.GET_ALL, async (_event, params: HistoryQueryParams) => {
|
||||
try {
|
||||
return ipcSuccess(getHistoryService().list(params))
|
||||
} catch {
|
||||
return ipcError(ErrorCode.DBQueryFailed, 'Failed to get history')
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error)
|
||||
return ipcError(ErrorCode.DBQueryFailed, `Failed to get history: ${message}`)
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.HISTORY.GET_BY_ID, async (_event, params: HistoryGetByIdParams) => {
|
||||
try {
|
||||
return ipcSuccess(getHistoryService().getById(params.id))
|
||||
} catch {
|
||||
return ipcError(ErrorCode.DBQueryFailed, 'Failed to get history entry')
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error)
|
||||
return ipcError(ErrorCode.DBQueryFailed, `Failed to get history entry: ${message}`)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -32,8 +34,9 @@ export function registerHistoryHandlers(): void {
|
|||
try {
|
||||
getHistoryService().delete(params.id)
|
||||
return ipcSuccess(undefined)
|
||||
} catch {
|
||||
return ipcError(ErrorCode.DBWriteFailed, 'Failed to delete history entry')
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error)
|
||||
return ipcError(ErrorCode.DBWriteFailed, `Failed to delete history entry: ${message}`)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -41,24 +44,27 @@ export function registerHistoryHandlers(): void {
|
|||
try {
|
||||
getHistoryService().deleteAll()
|
||||
return ipcSuccess(undefined)
|
||||
} catch {
|
||||
return ipcError(ErrorCode.DBWriteFailed, 'Failed to delete all history')
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error)
|
||||
return ipcError(ErrorCode.DBWriteFailed, `Failed to delete all history: ${message}`)
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.HISTORY.SEARCH, async (_event, params: HistorySearchParams) => {
|
||||
try {
|
||||
return ipcSuccess(getHistoryService().search(params))
|
||||
} catch {
|
||||
return ipcError(ErrorCode.DBQueryFailed, 'Failed to search history')
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error)
|
||||
return ipcError(ErrorCode.DBQueryFailed, `Failed to search history: ${message}`)
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle(IPC_CHANNELS.STATS.GET_SUMMARY, async () => {
|
||||
try {
|
||||
return ipcSuccess(getHistoryService().getStats())
|
||||
} catch {
|
||||
return ipcError(ErrorCode.DBQueryFailed, 'Failed to get stats')
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error)
|
||||
return ipcError(ErrorCode.DBQueryFailed, `Failed to get stats: ${message}`)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue