Hi,

I am trying to understand the new 1.2 error handling of agents.  For
this I created a minimal example which shows a strange behavior, at
least for my understanding

(def ag (agent 1))

(defn handler-fn [a e]
  (println "state of agent:" @a)
  (println "error:" e))

(defn raise-except-action [state new]
  (throw (Exception. "Action Exception")))

(set-error-mode! ag :continue)

Now, sending the exception raising function as an action to the agent
works just fine.  According to the error-mode it ignores the update.

(send ag raise-except-action)

But if I set an error handler like this:

(set-error-handler! ag handler-fn)

I see an exception when trying to send the above function again:

(send ag raise-except-action)

state of agent: 1
error: #<IllegalArgumentException
         java.lang.IllegalArgumentException:
         Wrong number of args (1) passed to:
         agent-errors$raise-except-action>

I don't understand why raise-except-action is called with just one
argument.  I did some more testing which showed that the one argument
passed to the action-fn is a list of the agent and the error.  And
this I understand even less.  But then, it was late in the night, when
I did this, so maybe that last information is not correct.

Any enlightenment, ideas?

Kind regards,
Stefan

;; Why is raise-except-action called?
;; Examining the args shows that it's a list of agent and error

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to