Mercurial > obsidian-remember-file-state
comparison src/main.ts @ 53:f2e066bbe343
Handle errors around reading the state database file.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 02 Oct 2023 10:07:26 -0700 |
parents | 586f857a98dd |
children | 06504ceb3283 |
comparison
equal
deleted
inserted
replaced
52:586f857a98dd | 53:f2e066bbe343 |
---|---|
485 | 485 |
486 private readonly readStateDatabase = async(path: string): Promise<void> => { | 486 private readonly readStateDatabase = async(path: string): Promise<void> => { |
487 const fs = this.app.vault.adapter; | 487 const fs = this.app.vault.adapter; |
488 if (await fs.exists(path)) { | 488 if (await fs.exists(path)) { |
489 const jsonDb = await fs.read(path); | 489 const jsonDb = await fs.read(path); |
490 this.data = JSON.parse(jsonDb); | 490 try |
491 const numLoaded = Object.keys(this.data.rememberedFiles).length; | 491 { |
492 console.debug(`RememberFileState: read ${numLoaded} record from state database.`); | 492 this.data = JSON.parse(jsonDb); |
493 const numLoaded = Object.keys(this.data.rememberedFiles).length; | |
494 console.debug(`RememberFileState: read ${numLoaded} record from state database.`); | |
495 } catch (err) { | |
496 console.error("RememberFileState: error loading state database:", err); | |
497 console.error(jsonDb); | |
498 } | |
493 } | 499 } |
494 } | 500 } |
495 | 501 |
496 private readonly setupLogFile = function(outLogPath: string) { | 502 private readonly setupLogFile = function(outLogPath: string) { |
497 console.log("RememberFileState: setting up log file: ", outLogPath); | 503 console.log("RememberFileState: setting up log file: ", outLogPath); |