Fork me on GitHub
#pathom
<
2020-03-29
>
yenda04:03:04

Am I doing something wrong or pathom return errors differently for resolvers and mutations? I have the following process-error function:

(defn process-error [env err]
  (if (ex-cause err)
    {:error {:cause (ex-cause err)
             :message (ex-message err)
             :data (ex-data err)}}
    (do (log/error "An error occured"
                   {:root-query (::p/root-query env)
                    :error (p/error-str err)})
        {:error {:cause :unexpected-error
                 :message "An error occured"}})))
When I throw an error in a mutation I get this kind of response:
{login
  {:error
   {:cause :login/invalid-email-or-password,
    :message "Invalid email or password",
    :data {:email-or-username ""}}}}
When I throw an error in a resolver I get:
{:auth/user :com.wsscode.pathom.core/reader-error,
  :com.wsscode.pathom.core/errors
  {[:auth/user]
   {:error
    {:cause :auth/invalid-token,
     :message "Invalid token",
     :data
     {:token "bad token"}}}}}}

yenda04:03:14

I would like the errors in mutations to be returned the same way as the resolvers