Add error handling for get-timeline

This commit is contained in:
kPherox 2019-05-22 16:32:30 +09:00
parent f00b0dd3f1
commit c0b89e99b0
No known key found for this signature in database
GPG Key ID: C04751C2BFA2F62D
2 changed files with 12 additions and 2 deletions

View File

@ -60,7 +60,11 @@ export default class Column extends Vue {
created() { created() {
// timelinenametypethis.id // timelinenametypethis.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.name = doc.name
this.type = doc.type this.type = doc.type

View File

@ -27,7 +27,13 @@ export default class Timeline {
public static ready() { public static ready() {
ipcMain.on('add-timeline', (event: Event, name: string, type: string) => this.onAddTimeline(event, name, type)) 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)) ipcMain.on('no-auth-timeline', (event: Event, name: string) => this.onNoAuthTimeline(event, name))