FIX error-interceptor-ctx keeps ctx state of non-erroring interceptor…
…s or :ctx from cause
previous: (:ctx data) was used to get ctx, or ctx started from scratch on
error for error-interceptors-chain
however, if a resource has (throw (ex-info "..." {:ctx yada-ctx})) then the
:ctx is likely on the cause (ex-cause e), so (some->> e ex-cause ex-data :ctx) gets the ctx if a user added it to ex-info
this isn't good enough, as if an error is thrown without user doing (try catch (throw (ex-info ...)) then we don't have the ctx anymore, but we
probably want the ctx for error reporting
the below code iterates through each interceptor and returns the last ctx state
before the interceptor chain throws. so now our error-interceptor-chain has
whatever ctx that existed when the error happened.
(let [partial-ctx
@(d/loop [ctx ctx
[interceptor & interceptors-rest] (:interceptor-chain ctx)]
(let [next-ctx (interceptor ctx)]
(if (instance? manifold.deferred.ErrorDeferred next-ctx)
ctx
(d/recur next-ctx interceptors-rest))))])