Author: toad
Date: 2005-11-10 17:38:28 +0000 (Thu, 10 Nov 2005)
New Revision: 7519

Added:
   trunk/freenet/src/freenet/client/events/BlockInsertErrorEvent.java
Modified:
   trunk/freenet/src/freenet/client/BlockInserter.java
   trunk/freenet/src/freenet/client/InserterException.java
   trunk/freenet/src/freenet/node/Version.java
Log:
156:
More bugs, more events.
Still doesn't work.

Modified: trunk/freenet/src/freenet/client/BlockInserter.java
===================================================================
--- trunk/freenet/src/freenet/client/BlockInserter.java 2005-11-10 17:23:51 UTC 
(rev 7518)
+++ trunk/freenet/src/freenet/client/BlockInserter.java 2005-11-10 17:38:28 UTC 
(rev 7519)
@@ -1,5 +1,6 @@
 package freenet.client;

+import freenet.client.events.BlockInsertErrorEvent;
 import freenet.keys.FreenetURI;
 import freenet.support.Bucket;
 import freenet.support.Logger;
@@ -96,14 +97,20 @@

        }

-       private void fatalError(Throwable e, int code) {
+       private void fatalError(InserterException e, int code) {
                Logger.normal(this, "Giving up on block: "+this+": "+e);
                tracker.fatalError(this, code);
+               ctx.eventProducer.produceEvent(new BlockInsertErrorEvent(e, 
uri, completedTries));
        }

-       private void nonfatalError(Exception e, int code) {
+       private void fatalError(Throwable t, int code) {
+               fatalError(new InserterException(code, t.toString()), code);
+       }
+
+       private void nonfatalError(InserterException e, int code) {
                Logger.minor(this, "Non-fatal error on "+this+": "+e);
                tracker.nonfatalError(this, code);
+               ctx.eventProducer.produceEvent(new BlockInsertErrorEvent(e, 
uri, completedTries));
        }

        protected void checkStartable() {

Modified: trunk/freenet/src/freenet/client/InserterException.java
===================================================================
--- trunk/freenet/src/freenet/client/InserterException.java     2005-11-10 
17:23:51 UTC (rev 7518)
+++ trunk/freenet/src/freenet/client/InserterException.java     2005-11-10 
17:38:28 UTC (rev 7519)
@@ -16,6 +16,12 @@
                return mode;
        }

+       public InserterException(int m, String msg) {
+               super(getMessage(m)+": "+msg);
+               mode = m;
+               errorCodes = null;
+       }
+       
        public InserterException(int m) {
                super(getMessage(m));
                mode = m;

Added: trunk/freenet/src/freenet/client/events/BlockInsertErrorEvent.java
===================================================================
--- trunk/freenet/src/freenet/client/events/BlockInsertErrorEvent.java  
2005-11-10 17:23:51 UTC (rev 7518)
+++ trunk/freenet/src/freenet/client/events/BlockInsertErrorEvent.java  
2005-11-10 17:38:28 UTC (rev 7519)
@@ -0,0 +1,27 @@
+package freenet.client.events;
+
+import freenet.client.InserterException;
+import freenet.keys.FreenetURI;
+
+public class BlockInsertErrorEvent implements ClientEvent {
+
+       public static final int code = 0x05;
+       public final InserterException e;
+       public final FreenetURI key;
+       public final int retryNumber;
+
+       public BlockInsertErrorEvent(InserterException e, FreenetURI key, int 
retryNumber) {
+               this.e = e;
+               this.key = key;
+               this.retryNumber = retryNumber;
+       }
+       
+       public String getDescription() {
+               return e.getMessage()+" for "+key+" ("+retryNumber+")";
+       }
+
+       public int getCode() {
+               return code;
+       }
+
+}

Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2005-11-10 17:23:51 UTC (rev 
7518)
+++ trunk/freenet/src/freenet/node/Version.java 2005-11-10 17:38:28 UTC (rev 
7519)
@@ -20,7 +20,7 @@
        public static final String protocolVersion = "1.0";

        /** The build number of the current revision */
-       public static final int buildNumber = 155;
+       public static final int buildNumber = 156;

        /** Oldest build of Fred we will talk to */
        public static final int lastGoodBuild = 153;


Reply via email to