Fork me on GitHub

This is not really yada related but probably people here can give some advice anyways: I’m building pipeline system and want to add something like interceptors (in contrast to with-db-conn macros and similar) that inject stuff into the pipeline’s context. One thing I’m wondering is how error handling is implemented with interceptors. E.g. an interceptor takes a resource from a pool. How do I make sure it’s returned on failure (or marked as broken)?


One option I can think of is an inteceptor impl like this:

(defprotocol Intercept
  (before [this ctx])
  (after [this ctx])
  (error [this ctx exception]))
but I haven’t ever implemented a system like this so I’m looking for someone who has and may be able to give feedback


@martinklepsch is this perhaps something that could be addressed using manifold’s error mechanism ?


as in, i would almost think of an interceptor chain as a manifold stream


I don’t need async right now, more interested in using it to add “do before” “do after” stuff to my pipeline


so yeah, in your interceptor protocol impl, i would just try to model the try / catch / finally mechanism, which has proven to be powerful 🙂


@lmergen how do you mean model try/catch/finally


so, in your example, it would become

(defprotocol Intercept
  (before [this ctx])
  (after [this ctx])
  (catch [this ctx exception])
  (finally [this ctx]))


at least, this feels like a familiar mechanism to handle error reporting


Ah, I see what you mean, that makes sense, thanks!