Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make error-formatting work from servers #604

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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