enhance: improve error handling for exports + imports

Display user friendly notification when unexpected failures occur.
Also actively validate export to ensure it can even import
This commit is contained in:
Gabriel Horner
2025-02-13 13:57:39 -05:00
parent dd97879e81
commit 7da4f7a9b7
4 changed files with 88 additions and 30 deletions

View File

@@ -59,9 +59,13 @@
(if (= ::invalid-import export-map)
(notification/show! "The submitted EDN data is invalid! Fix and try again." :warning)
(let [{:keys [init-tx block-props-tx error] :as txs}
(sqlite-export/build-import export-map
(db/get-db)
(when block {:current-block block}))]
(try
(sqlite-export/build-import export-map
(db/get-db)
(when block {:current-block block}))
(catch :default e
(js/console.error "Import EDN error: " e)
{:error "An unexpected error occurred during import. See the javascript console for details."}))]
(pprint/pprint txs)
(if error
(notification/show! error :error)