# HG changeset patch # User Ludovic Chabant # Date 1696266446 25200 # Node ID f2e066bbe343b5b7ccfae4a14c44239c9fce59e4 # Parent 586f857a98dd76f92069f522de24a6ccd0126a19 Handle errors around reading the state database file. diff -r 586f857a98dd -r f2e066bbe343 src/main.ts --- a/src/main.ts Mon Oct 02 10:05:02 2023 -0700 +++ b/src/main.ts Mon Oct 02 10:07:26 2023 -0700 @@ -487,9 +487,15 @@ const fs = this.app.vault.adapter; if (await fs.exists(path)) { const jsonDb = await fs.read(path); - this.data = JSON.parse(jsonDb); - const numLoaded = Object.keys(this.data.rememberedFiles).length; - console.debug(`RememberFileState: read ${numLoaded} record from state database.`); + try + { + this.data = JSON.parse(jsonDb); + const numLoaded = Object.keys(this.data.rememberedFiles).length; + console.debug(`RememberFileState: read ${numLoaded} record from state database.`); + } catch (err) { + console.error("RememberFileState: error loading state database:", err); + console.error(jsonDb); + } } }