scambier / obsidian-omnisearch

A search engine that "just works" for Obsidian. Supports OCR and PDF indexing.
GNU General Public License v3.0
1.26k stars 65 forks source link

Fix uncaught exceptions #414

Closed baodrate closed 3 weeks ago

baodrate commented 3 weeks ago

Fixed some uncaught exceptions that were bugging me.

Canvas file parsing errors After "Canvas: Create new canvas" command: ```stacktrace documents-repository.ts:53 Omnisearch: Error while adding "Untitled.canvas" to live cache SyntaxError: Unexpected end of JSON input at JSON.parse () at DocumentsRepository.getAndMapIndexedDocument (documents-repository.ts:100:27) at async DocumentsRepository.addDocument (documents-repository.ts:43:19) at async DocumentsRepository.getDocument (documents-repository.ts:69:5) at async eval (search-engine.ts:82:25) at async Promise.all (index 0) at async SearchEngine.addFromPaths (search-engine.ts:80:7) ``` After saving the empty canvas file: ```stacktrace documents-repository.ts:53 Omnisearch: Error while adding "Untitled.canvas" to live cache TypeError: canvas.nodes is not iterable at DocumentsRepository.getAndMapIndexedDocument (documents-repository.ts:103:33) at async DocumentsRepository.addDocument (documents-repository.ts:43:19) at async NotesIndexer.refreshIndex (notes-indexer.ts:29:7) ```
Error on `mkdir foobar` For example, after running `mkdir foobar` in the vault directory, the following exception is thrown: ```stacktrace documents-repository.ts:53 Omnisearch: Error while adding "foobar" to live cache Error: Not a TFile: "foobar" at DocumentsRepository.getAndMapIndexedDocument (documents-repository.ts:85:41) at DocumentsRepository.addDocument (documents-repository.ts:43:30) at DocumentsRepository.getDocument (documents-repository.ts:69:16) at eval (search-engine.ts:82:63) at Array.map () at SearchEngine.addFromPaths (search-engine.ts:81:15) at eval (main.ts:114:26) at e.tryTrigger (app.js:1:723011) at e.trigger (app.js:1:722944) at t.trigger (app.js:1:741049) ```
scambier commented 3 weeks ago

Thank you :)