Skip to content

Commit

Permalink
Merge pull request #604 from fluree/feature/fix-errors-for-servers
Browse files Browse the repository at this point in the history
  • Loading branch information
mpoffald authored Oct 26, 2023
2 parents a7da681 + 7035129 commit 6320e16
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/fluree/db/query/history.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
(if at
(not (or from to))
(or from to)))]
[:fn {:error/message "\"from\" value must be less than or equal to \"to\" value,"}
[:fn {:error/message "\"from\" value must be less than or equal to \"to\" value"}
(fn [{:keys [from to]}] (if (and (number? from) (number? to))
(<= from to)
true))]]]]
Expand Down
16 changes: 13 additions & 3 deletions src/fluree/db/validation.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,22 @@
(recur (pop path) (last path) path' p' m')
(when m [(if (seq in) (mu/path->in schema path') (me/error-path error options)) m' p']))))))

(def top-level-query-keys
#{:select
:where
:group-by
:groupBy
:order-by
:orderBy
:commit-details
:t
:history})

(defn format-error
[explained error error-opts]
(let [{:keys [path value]} error
top-level-key (when-not (= ::m/extra-key (:type error))
(some-> (first (filter keyword? path))
name))
top-level-key (some-> (first (filter top-level-query-keys path))
name)
top-level-message (when top-level-key
(str "Error in value for \"" top-level-key "\""))
[_ root-message] (resolve-root-error-for-in
Expand Down

0 comments on commit 6320e16

Please sign in to comment.