mirror of https://github.com/logseq/logseq
Add try/catch for unexpected failures during block extraction
Notify user and sentry when unexpected errors occurpull/5610/head^2
parent
01b28e26ee
commit
538aea0437
|
@ -6,19 +6,27 @@
|
|||
[frontend.db :as db]
|
||||
[frontend.format :as format]
|
||||
[frontend.state :as state]
|
||||
[frontend.handler.notification :as notification]
|
||||
["@sentry/react" :as Sentry]
|
||||
[logseq.graph-parser.config :as gp-config]
|
||||
[logseq.graph-parser.property :as gp-property]
|
||||
[logseq.graph-parser.mldoc :as gp-mldoc]))
|
||||
|
||||
(defn extract-blocks
|
||||
"Wrapper around logseq.graph-parser.block/extract-blocks that adds in system state"
|
||||
"Wrapper around logseq.graph-parser.block/extract-blocks that adds in system state
|
||||
and handles unexpected failure."
|
||||
[blocks content with-id? format]
|
||||
(gp-block/extract-blocks blocks content with-id? format
|
||||
{:user-config (state/get-config)
|
||||
:block-pattern (config/get-block-pattern format)
|
||||
:supported-formats (gp-config/supported-formats)
|
||||
:db (db/get-db (state/get-current-repo))
|
||||
:date-formatter (state/get-date-formatter)}))
|
||||
(try
|
||||
(gp-block/extract-blocks blocks content with-id? format
|
||||
{:user-config (state/get-config)
|
||||
:block-pattern (config/get-block-pattern format)
|
||||
:supported-formats (gp-config/supported-formats)
|
||||
:db (db/get-db (state/get-current-repo))
|
||||
:date-formatter (state/get-date-formatter)})
|
||||
(catch :default e
|
||||
(Sentry/captureException e)
|
||||
(notification/show! "An unexpected error occurred during block extraction." :error)
|
||||
[])))
|
||||
|
||||
(defn page-name->map
|
||||
"Wrapper around logseq.graph-parser.block/page-name->map that adds in db"
|
||||
|
|
|
@ -45,4 +45,4 @@
|
|||
(defn init []
|
||||
(when-not config/dev?
|
||||
(let [config (clj->js config)]
|
||||
(Sentry/init config))))
|
||||
(Sentry/init config))))
|
||||
|
|
Loading…
Reference in New Issue