The info is there, but as you say it isn't very obvious.
I'm happy to submit a trivial patch which would change the error
message to include the agent's error string.

For example, before patch:
user=> (def a (agent 0))
user=> (send a (partial / 10))
user=> @a
java.lang.Exception: Agent has errors (NO_SOURCE_FILE:0)
user=> (.printStackTrace *e)
java.lang.Exception: Agent has errors (NO_SOURCE_FILE:0)
...
Caused by: java.lang.Exception: Agent has errors
...
Caused by: java.lang.ArithmeticException: Divide by zero
...


After patch:
user=> (def a (agent 0))
#'user/a
user=>  (send a (partial / 10))
java.lang.ArithmeticException: Divide by zero
user=> @a
java.lang.Exception: Agent has error: Divide by zero (NO_SOURCE_FILE:
0)


index 310c826..2e8957b 100644
--- a/src/jvm/clojure/lang/Agent.java
+++ b/src/jvm/clojure/lang/Agent.java
@@ -126,7 +126,8 @@ boolean setState(Object newState) throws Exception
{
 public Object deref() throws Exception{
        if(errors != null)
                {
-               throw new Exception("Agent has errors", (Exception)
RT.first(errors));
+                Exception ee = (Exception) RT.first(errors);
+               throw new Exception("Agent has error: "+ee.getMessage
(), ee);
                }
        return state;
 }

Rich let me know if you want a ticket for this or not, or more
discussion.


Regards,
Tim.


On Sep 22, 3:19 am, Raoul Duke <rao...@gmail.com> wrote:
> > The error would have occured in the (send ....) where the drawing is
> > done. @agent is not causing it, but you do get an exception there
> > because of the previous exception while drawing. To debug this I
> > suggest inserting some printlns into the function you are sending.
>
> thanks! that makes sense.
>
> (would be neat if there were a way for it to be more obvious in the
> stack trace / error message from Clojure)?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to