eep icon indicating copy to clipboard operation
eep copied to clipboard

Debugging topologies

Open arr-ee opened this issue 12 years ago • 4 comments

I’ve ran into an issue with buggy topologies. When one of the processing functions throws an exception, further execution stops and exception gets swallowed.

That behaviour is pretty okay, but it’d be nice to know that exception actually occurred (to debug/throw in exception reporter/etc). I remember that @ifesdjeen told me on twitter about special handlers in Meltdown and EEP’s wrap-debug macro, but I’m probably too stupid to figure out how they work.

It’d be nice to have a smallish chapter on debugging somewhere in docs or README.

Thanks!

arr-ee avatar Oct 14 '13 13:10 arr-ee

You can subscribe to the events of exception class, for example:

(add-handler Exception (fn [e] ...)

I'll also add custom ErrorHandlers to topologies....

For wrap-debug you would do something like

(add-handler :key (wrap-debug (fn [..] ...))

And it will add a debug try-catch block over fn. The documentation will be improved shortly.

ifesdjeen avatar Oct 15 '13 01:10 ifesdjeen

I’m really sorry for being so slow, but neither of those approaches worked for me.

Here’s what I’ve tried:

(e/deftransformer emitter :e #(throw (Exception. "!")) :processed)
(e/add-handler emitter Exception (fn [e] (println e)))

Transformer should blow up all over the place (wrong arity + throw), but it prints nothing.

wrap-debug still confuses me with it’s signature — it looks like a handler fn (emitter, type and processing fn), but doesn’t register as a handler if I just drop it in (i.e. doesn’t appear in topology). It also swallows emitter passed to it, so I figure it should wrap the function passed to handler, but in that case it has too many args.

Again, please excuse me for all the questions — I’m really new to Clojure, so sometimes I don’t see obvious things.

Thanks!

arr-ee avatar Oct 15 '13 07:10 arr-ee

Started working on a prototype, hope to release tomorrow :)

ifesdjeen avatar Oct 15 '13 22:10 ifesdjeen

Ok, got it done for meltdown: https://github.com/clojurewerkz/meltdown/commit/0b959fc989816e4895f2c96fc196267858176d8f

Working on same thing for EEP :)

ifesdjeen avatar Oct 17 '13 18:10 ifesdjeen