mirror of https://github.com/logseq/logseq
chore: Remove unnecessary catch and rethrow for notification
Just encode notification in original exception to make conversion as reusable as possible. Also make properties readable with :original-name as they are case sensitiveexperiment/tanstack-table
parent
a17ed389e8
commit
efab7f403e
|
@ -50,7 +50,10 @@
|
||||||
[v-str]
|
[v-str]
|
||||||
(let [result (parse-double v-str)]
|
(let [result (parse-double v-str)]
|
||||||
(or result
|
(or result
|
||||||
(throw (js/Error. (str "Can't convert \"" v-str "\" to a number"))))))
|
(throw (ex-info (str "Can't convert \"" v-str "\" to a number")
|
||||||
|
{:type :notification
|
||||||
|
:payload {:message (str "Can't convert \"" v-str "\" to a number")
|
||||||
|
:type :error}})))))
|
||||||
|
|
||||||
(defn ^:api convert-property-input-string
|
(defn ^:api convert-property-input-string
|
||||||
[schema-type v-str]
|
[schema-type v-str]
|
||||||
|
@ -447,15 +450,7 @@
|
||||||
property-type (get property-schema :type :default)]
|
property-type (get property-schema :type :default)]
|
||||||
(when (contains? db-property-type/closed-value-property-types property-type)
|
(when (contains? db-property-type/closed-value-property-types property-type)
|
||||||
(let [value' (if (string? value) (string/trim value) value)
|
(let [value' (if (string? value) (string/trim value) value)
|
||||||
resolved-value (try
|
resolved-value (convert-property-input-string (:type property-schema) value')
|
||||||
(convert-property-input-string (:type property-schema) value')
|
|
||||||
(catch :default e
|
|
||||||
(js/console.error e)
|
|
||||||
(throw (ex-info "Property converted failed"
|
|
||||||
{:type :notification
|
|
||||||
:payload {:message (str e)
|
|
||||||
:type :error}}))
|
|
||||||
nil))
|
|
||||||
validate-message (validate-property-value
|
validate-message (validate-property-value
|
||||||
(get-property-value-schema @conn property-type property {:new-closed-value? true})
|
(get-property-value-schema @conn property-type property {:new-closed-value? true})
|
||||||
resolved-value)]
|
resolved-value)]
|
||||||
|
@ -474,7 +469,6 @@
|
||||||
:type :warning}}))
|
:type :warning}}))
|
||||||
|
|
||||||
validate-message
|
validate-message
|
||||||
|
|
||||||
;; Make sure to update frontend.handler.db-based.property-test when updating ex-info message
|
;; Make sure to update frontend.handler.db-based.property-test when updating ex-info message
|
||||||
(throw (ex-info "Invalid property value"
|
(throw (ex-info "Invalid property value"
|
||||||
{:error :value-invalid
|
{:error :value-invalid
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
(when-let [block (db-utils/entity [:block/uuid %])]
|
(when-let [block (db-utils/entity [:block/uuid %])]
|
||||||
(db-property/closed-value-name block))
|
(db-property/closed-value-name block))
|
||||||
%)]
|
%)]
|
||||||
[(-> prop-ent :block/name keyword)
|
[(-> prop-ent :block/original-name keyword)
|
||||||
(if (set? v)
|
(if (set? v)
|
||||||
(set (map readable-property-val v))
|
(set (map readable-property-val v))
|
||||||
(readable-property-val v))])))
|
(readable-property-val v))])))
|
||||||
|
|
|
@ -300,7 +300,7 @@
|
||||||
(is
|
(is
|
||||||
(thrown-with-msg?
|
(thrown-with-msg?
|
||||||
js/Error
|
js/Error
|
||||||
#"Property converted failed"
|
#"Can't convert"
|
||||||
(outliner-property/upsert-closed-value! conn (:db/id property) {:value "not a number"})))
|
(outliner-property/upsert-closed-value! conn (:db/id property) {:value "not a number"})))
|
||||||
(let [values (get-value-ids k)]
|
(let [values (get-value-ids k)]
|
||||||
(is (= #{"1" "2"} (get-closed-values values)))))
|
(is (= #{"1" "2"} (get-closed-values values)))))
|
||||||
|
|
Loading…
Reference in New Issue