enhance(ux): catch component errors

This commit is contained in:
charlie
2024-08-06 14:17:29 +08:00
parent 8fe21b2405
commit d151ec755f
3 changed files with 11 additions and 6 deletions

View File

@@ -3166,10 +3166,15 @@
(assoc config :container-id container-id)
config)]
(when (:block/uuid block)
(rum/with-key
(block-container-inner state repo config' block
{:navigating-block navigating-block :navigated? navigated?})
(str "block-inner" (:block/uuid block))))))
(ui/catch-error
(fn [^js error]
[:div.flex.flex-col.pl-6.my-1
[:code (str "#uuid\"" (:block/uuid block) "\"")]
[:code.flex.p-1.text-red-rx-09 "Block render error: " (.-message error)]])
(rum/with-key
(block-container-inner state repo config' block
{:navigating-block navigating-block :navigated? navigated?})
(str "block-inner" (:block/uuid block)))))))
(defn divide-lists
[[f & l]]

View File

@@ -623,7 +623,7 @@
{:on-click (fn []
(handle-delete-property! block property {:class-schema? class-schema?})
(shui/popup-hide!))}
[:span.w-full.text-red-rx-07.hover:text-red-rx-09
[:span.w-full.text-red-rx-09
"Delete property"]))]
{:as-dropdown? true
:content-props {:class "w-48"}}))}

View File

@@ -790,7 +790,7 @@
(assoc state ::error error))}
[{error ::error, c :rum/react-component} error-view view]
(if (some? error)
error-view
(if (fn? error-view) (error-view error) error-view)
view))
(rum/defcs catch-error-and-notify