[Webfunds-commits] java/webfunds/sox SOXSubAccountException.java SubAccount.java

Ian Grigg iang@cypherpunks.ai
Sun, 11 Jun 2000 18:30:43 -0400 (AST)


iang        00/06/11 18:30:43

  Modified:    webfunds/sox SOXSubAccountException.java SubAccount.java
  Log:
  Added some numbers to SOXSubAccountException and throws with numbers
  in the SubAccount.  Probably needs to be redone into different Exs.

Revision  Changes    Path
1.3       +14 -2     java/webfunds/sox/SOXSubAccountException.java

Index: SOXSubAccountException.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/SOXSubAccountException.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SOXSubAccountException.java	2000/03/19 23:06:20	1.2
+++ SOXSubAccountException.java	2000/06/11 22:30:43	1.3
@@ -1,5 +1,5 @@
 /*
- * $Id: SOXSubAccountException.java,v 1.2 2000/03/19 23:06:20 iang Exp $
+ * $Id: SOXSubAccountException.java,v 1.3 2000/06/11 22:30:43 iang Exp $
  *
  * Copyright (c) Systemics Ltd 1995-1999 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -14,7 +14,19 @@
     extends SOXException
 {
 
-    public static final int   FROZEN = 2;
+    /**
+     *  Internal errors detected.
+     *  Positive numbers are unexpected SOX reply errors.
+     */
+    public static final int   FROZEN         = -2,
+                              SERVER_DOWN    = -3,
+                              NO_SERVER      = -4,
+                              BAD_PACKET     = -5;
+
+    public boolean isFrozen()           { return (number == FROZEN); }
+    public boolean isServerDown()       { return (number == SERVER_DOWN); }
+    public boolean isNoServer()         { return (number == NO_SERVER); }
+    public boolean isBadPacket()        { return (number == BAD_PACKET); }
 
     public SOXSubAccountException(String msg)
     {



1.21      +13 -8     java/webfunds/sox/SubAccount.java

Index: SubAccount.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/SubAccount.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- SubAccount.java	2000/04/20 00:04:44	1.20
+++ SubAccount.java	2000/06/11 22:30:43	1.21
@@ -1,5 +1,5 @@
 /*
- * $Id: SubAccount.java,v 1.20 2000/04/20 00:04:44 iang Exp $
+ * $Id: SubAccount.java,v 1.21 2000/06/11 22:30:43 iang Exp $
  *
  * Copyright (c) Systemics Ltd 1995-1999 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -125,12 +125,13 @@
         try {
             issuer = acct.getIssuer(itemId);
         } catch (SOXIssuerException ex) {
-            throw new SOXSubAccountException("no issuer available for " +
-                                             itemId + " : " + ex);
+            throw new SOXSubAccountException(SOXSubAccountException.NO_SERVER,
+                      "no SOX server available for " + itemId + " : " + ex);
         }
 
         if (issuer == null)
-            throw new SOXSubAccountException("no issuer for " + itemId);
+            throw new SOXSubAccountException(SOXSubAccountException.NO_SERVER,
+                      "no SOX server available for " + itemId);
 
         return issuer ;
     }
@@ -243,7 +244,8 @@
             reply = new RegisterReply(replyBuf);
         } catch (SOXPacketException ex) {
             ex.printStackTrace(System.err);
-            throw new SOXSubAccountException("SOXPacketException: " + ex);
+            throw new SOXSubAccountException(SOXSubAccountException.BAD_PACKET,
+                      "SOXPacketException: " + ex);
         }
 
 
@@ -254,7 +256,8 @@
         else if (err == Errors.ERROR_LATER)
             throw new SOXLaterException(err, txt);
         else
-            throw new SOXSubAccountException("Failed (" + err + ") " + txt);
+            throw new SOXSubAccountException(err,
+                      "Failed (" + err + ") " + txt);
 
         if (isNew())
             status |= REGISTERED;
@@ -277,7 +280,8 @@
         try {
             replyBuf = issuer.request(req);
         } catch (SOXIssuerException iex) {
-            throw new SOXSubAccountException("issers failed?" + iex);
+            throw new SOXSubAccountException(SOXSubAccountException.SERVER_DOWN,
+                      "SOXIEx: " + iex);
         }
         return replyBuf;
     }
@@ -321,7 +325,8 @@
             reply = new MailReply(replyBuf);
         } catch (SOXPacketException ex) {
             ex.printStackTrace(System.err);
-            throw new SOXSubAccountException("SOXPacketException: " + ex);
+            throw new SOXSubAccountException(SOXSubAccountException.BAD_PACKET,
+                      "SOXPacketException: " + ex);
         }
 
         int err = reply.getErrorNumber();