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]
|
||||
(let [result (parse-double v-str)]
|
||||
(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
|
||||
[schema-type v-str]
|
||||
|
@ -447,15 +450,7 @@
|
|||
property-type (get property-schema :type :default)]
|
||||
(when (contains? db-property-type/closed-value-property-types property-type)
|
||||
(let [value' (if (string? value) (string/trim value) value)
|
||||
resolved-value (try
|
||||
(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))
|
||||
resolved-value (convert-property-input-string (:type property-schema) value')
|
||||
validate-message (validate-property-value
|
||||
(get-property-value-schema @conn property-type property {:new-closed-value? true})
|
||||
resolved-value)]
|
||||
|
@ -474,7 +469,6 @@
|
|||
:type :warning}}))
|
||||
|
||||
validate-message
|
||||
|
||||
;; Make sure to update frontend.handler.db-based.property-test when updating ex-info message
|
||||
(throw (ex-info "Invalid property value"
|
||||
{:error :value-invalid
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
(when-let [block (db-utils/entity [:block/uuid %])]
|
||||
(db-property/closed-value-name block))
|
||||
%)]
|
||||
[(-> prop-ent :block/name keyword)
|
||||
[(-> prop-ent :block/original-name keyword)
|
||||
(if (set? v)
|
||||
(set (map readable-property-val v))
|
||||
(readable-property-val v))])))
|
||||
|
|
|
@ -300,7 +300,7 @@
|
|||
(is
|
||||
(thrown-with-msg?
|
||||
js/Error
|
||||
#"Property converted failed"
|
||||
#"Can't convert"
|
||||
(outliner-property/upsert-closed-value! conn (:db/id property) {:value "not a number"})))
|
||||
(let [values (get-value-ids k)]
|
||||
(is (= #{"1" "2"} (get-closed-values values)))))
|
||||
|
|
Loading…
Reference in New Issue