- 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
61 lines
2.3 KiB
TypeScript
61 lines
2.3 KiB
TypeScript
// src/main/ipc/dictionary-handlers.ts
|
|
|
|
import { ipcMain } from 'electron'
|
|
import { IPC_CHANNELS } from '@d3ro/core/ipc-channels'
|
|
import { ipcSuccess, ipcError, ErrorCode } from '@d3ro/core/errors'
|
|
import { getDictionaryService } from '../services/DictionaryService'
|
|
import type {
|
|
DictionaryQueryParams,
|
|
DictionaryAddParams,
|
|
DictionaryUpdateParams,
|
|
DictionaryDeleteParams,
|
|
DictionarySearchParams
|
|
} from '@d3ro/core/types'
|
|
|
|
export function registerDictionaryHandlers(): void {
|
|
ipcMain.handle(IPC_CHANNELS.DICTIONARY.GET_ALL, async (_event, params: DictionaryQueryParams) => {
|
|
try {
|
|
return ipcSuccess(getDictionaryService().list(params))
|
|
} catch (error) {
|
|
const message = error instanceof Error ? error.message : String(error)
|
|
return ipcError(ErrorCode.DBQueryFailed, `Failed to get dictionary: ${message}`)
|
|
}
|
|
})
|
|
|
|
ipcMain.handle(IPC_CHANNELS.DICTIONARY.ADD, async (_event, params: DictionaryAddParams) => {
|
|
try {
|
|
return ipcSuccess(getDictionaryService().add(params))
|
|
} catch (error) {
|
|
const message = error instanceof Error ? error.message : String(error)
|
|
return ipcError(ErrorCode.DBWriteFailed, `Failed to add dictionary entry: ${message}`)
|
|
}
|
|
})
|
|
|
|
ipcMain.handle(IPC_CHANNELS.DICTIONARY.UPDATE, async (_event, params: DictionaryUpdateParams) => {
|
|
try {
|
|
return ipcSuccess(getDictionaryService().update(params))
|
|
} catch (error) {
|
|
const message = error instanceof Error ? error.message : String(error)
|
|
return ipcError(ErrorCode.DBWriteFailed, `Failed to update dictionary entry: ${message}`)
|
|
}
|
|
})
|
|
|
|
ipcMain.handle(IPC_CHANNELS.DICTIONARY.DELETE, async (_event, params: DictionaryDeleteParams) => {
|
|
try {
|
|
getDictionaryService().delete(params.id)
|
|
return ipcSuccess(undefined)
|
|
} catch (error) {
|
|
const message = error instanceof Error ? error.message : String(error)
|
|
return ipcError(ErrorCode.DBWriteFailed, `Failed to delete dictionary entry: ${message}`)
|
|
}
|
|
})
|
|
|
|
ipcMain.handle(IPC_CHANNELS.DICTIONARY.SEARCH, async (_event, params: DictionarySearchParams) => {
|
|
try {
|
|
return ipcSuccess(getDictionaryService().search(params))
|
|
} catch (error) {
|
|
const message = error instanceof Error ? error.message : String(error)
|
|
return ipcError(ErrorCode.DBQueryFailed, `Failed to search dictionary: ${message}`)
|
|
}
|
|
})
|
|
}
|