Add error handling for get-timeline

This commit is contained in:
kPherox
2019-05-22 16:32:30 +09:00
parent f00b0dd3f1
commit c0b89e99b0
2 changed files with 12 additions and 2 deletions

View File

@@ -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

View File

@@ -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))