Fork me on GitHub
#pathom
<
2022-03-15
>
aratare07:03:06

Hi there. What is the best way to catch and handle exceptions thrown within a mutation? E.g. I have a simple mutation that creates an entry in the database. If I feed bad input, the database will throw an exception but I can't seem to catch and process it with error-handler-plugin and ::pc/process-error, i.e. the provided error handling function is not triggered. I can, of course, handling it per mutation but I'd rather have a global handler that will take care of this for me. Thanks in advance.

aratare07:03:45

Here's what I have for the parser

(p/parser {::p/env     {::p/reader                 [p/map-reader pc/reader2 pc/ident-reader pc/index-reader]
                          ::pc/mutation-join-globals [:tempids]
                          ::pc/process-error         (fn [env err]
                                                       (log/spy env)
                                                       (.printStackTrace err)
                                                       (p/error-str err))}
             ::p/mutate  pc/mutate
             ::p/plugins [(pc/connect-plugin {::pc/register resolvers})
                          p/error-handler-plugin
                          (p/post-process-parser-plugin p/elide-not-found)]})
As stated previously there is no stacktrace printed.

wilkerlucio20:03:27

@U013F1Q1R7G there is a typo, its ::p/process-error instead of ::pc/process-error

aratare05:03:29

Ah silly me 😅

aratare06:03:52

It's working perfectly now. Thank you 🙂

wilkerlucio13:03:15

no worries, sorry for the sometimes confusing namespaces 😅

aratare07:03:44

All is well 😄 It's my fault for not paying enough attention 🙂