Fork me on GitHub
#pathom
<
2019-09-05
>
kenny01:09:46

Isn't this supposed to place errors on the same level as the attribute? Perhaps I am missing something about how this is supposed to be used.

(p/raise-errors {:metric/provider-points :com.wsscode.pathom.core/reader-error,
                 :com.wsscode.pathom.core/errors
                                         {[:metric/provider-points]
                                          {:cognitect.anomalies/category :cognitect.anomalies/incorrect,
                                           :cognitect.anomalies/message  "foo"}}})
=>
{:metric/provider-points :com.wsscode.pathom.core/reader-error,
 :com.wsscode.pathom.core/errors #:metric{:provider-points #:cognitect.anomalies{:category :cognitect.anomalies/incorrect,
                                                                                 :message "foo"}}}

kenny01:09:17

This seems more in line with what I expected:

(defn raise-reader-errors
  [parser-output-data]
  (reduce
    (fn [m [path err]]
      (if (= ::p/reader-error (get-in m path))
        (assoc-in m path err)
        m))
    (dissoc parser-output-data :com.wsscode.pathom.core/errors)
    (get parser-output-data :com.wsscode.pathom.core/errors)))

wilkerlucio17:09:32

@kenny your case is a bit different because its an error in the root, thats interesting case to see, most of the time the queries I use have an ident at the root (so provide some data), in case your error is at the root, then the error position is already correct, makes sense?

kenny00:09:44

get at the path :metric/provider-points does not return the error.