From c0b89e99b04bd84bb70d08bcb13bffd308e83a90 Mon Sep 17 00:00:00 2001 From: kPherox Date: Wed, 22 May 2019 16:32:30 +0900 Subject: [PATCH] Add error handling for `get-timeline` --- src/components/Timeline/Column.vue | 6 +++++- src/main/Timeline.ts | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/Timeline/Column.vue b/src/components/Timeline/Column.vue index 0dc8a4aa..c3594075 100644 --- a/src/components/Timeline/Column.vue +++ b/src/components/Timeline/Column.vue @@ -60,7 +60,11 @@ export default class Column extends Vue { created() { // timelineのnameとtypeをthis.idから取得する - let doc: TimelineDoc = ipcRenderer.sendSync('get-timeline', this.id) + let doc: TimelineDoc | null = ipcRenderer.sendSync('get-timeline', this.id) + if (doc === null) { + this.$destroy() + return + } this.name = doc.name this.type = doc.type diff --git a/src/main/Timeline.ts b/src/main/Timeline.ts index 4c2d80d1..7e32ee0c 100644 --- a/src/main/Timeline.ts +++ b/src/main/Timeline.ts @@ -27,7 +27,13 @@ export default class Timeline { public static ready() { ipcMain.on('add-timeline', (event: Event, name: string, type: string) => this.onAddTimeline(event, name, type)) - ipcMain.on('get-timeline', async (event: Event, id: string) => event.returnValue = await this.getTimeline(id)) + ipcMain.on('get-timeline', async (event: Event, id: string) => { + try { + event.returnValue = await this.getTimeline(id) + } catch (error) { + event.returnValue = null + } + }) ipcMain.on('no-auth-timeline', (event: Event, name: string) => this.onNoAuthTimeline(event, name))