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

Ian Grigg iang@cypherpunks.ai
Thu, 13 Jul 2000 20:02:32 -0400 (AST)


iang        00/07/13 20:02:32

  Modified:    webfunds/client/sox SOXWallet.java
               webfunds/sox SOXIssuerException.java
                        SOXSubAccountException.java SubAccount.java
  Log:
  Added numbers to Exceptions so that SOXWallet can handle the
  non-existant contract problem on deposit (by returning a useful error).

Revision  Changes    Path
1.128     +19 -1     java/webfunds/client/sox/SOXWallet.java

Index: SOXWallet.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/sox/SOXWallet.java,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -r1.127 -r1.128
--- SOXWallet.java	2000/07/07 01:53:52	1.127
+++ SOXWallet.java	2000/07/14 00:02:31	1.128
@@ -1,4 +1,4 @@
-/* $Id: SOXWallet.java,v 1.127 2000/07/07 01:53:52 iang Exp $
+/* $Id: SOXWallet.java,v 1.128 2000/07/14 00:02:31 iang Exp $
  *
  * Copyright (c) Systemics Inc. 1995-2000 on behalf of
  * The WebFunds Development Team.  All Rights Reserved.
@@ -764,9 +764,27 @@
             try {
                 ac.newSub(sub);
             } catch (SOXSubAccountException ex) {
+                if (ex.isNoContract())
+                {
+                    error(
+                      "It is not possible to deposit this payment because\n"+
+                      "the SOX Issuer server cannot be identified or found\n"+
+                      "(normally pointed to by the Ricardian Contract)!\n"+
+                      "\n"+
+                      "In order to deposit this payment, you must find the\n"+
+                      "the contract that has identifier:\n"+
+                      "\n"+
+                      "               " + item + "\n"+
+                      "\n"+
+                      "and add it to the Contract Store using the Plugins /\n"+
+                      "Contract Browser button.\n"+
+                      "");
+                      return ;
+                }
                 ex.printStackTrace();
                 error("cannot create SubAccount: " + ex);
                 return ;
+
             } catch (SOXAccountException ex) {
                 ex.printStackTrace();
                 error("Account error: " + ex);



1.2       +9 -5      java/webfunds/sox/SOXIssuerException.java

Index: SOXIssuerException.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/SOXIssuerException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- SOXIssuerException.java	1999/09/23 23:58:52	1.1
+++ SOXIssuerException.java	2000/07/14 00:02:31	1.2
@@ -1,5 +1,5 @@
 /*
- * $Id: SOXIssuerException.java,v 1.1 1999/09/23 23:58:52 iang Exp $
+ * $Id: SOXIssuerException.java,v 1.2 2000/07/14 00:02:31 iang Exp $
  *
  * Copyright (c) Systemics Ltd 1995-1999 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -13,9 +13,13 @@
 public class SOXIssuerException
     extends SOXException
 {
+    public final static int UNKNOWN     = -1,
+			    NO_CONTRACT = -6; // contract points to server
 
-    public SOXIssuerException(String msg)
-    {
-        super(msg);
-    }
+    public boolean isNoContract()  { return number == NO_CONTRACT ; }
+
+    public SOXIssuerException(String msg)            { super(UNKNOWN, msg); }
+    public SOXIssuerException(int errno, String msg) { super(errno, msg); }
+    public SOXIssuerException(int errno)             { super(errno, ""); }
+
 }



1.4       +4 -2      java/webfunds/sox/SOXSubAccountException.java

Index: SOXSubAccountException.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/SOXSubAccountException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SOXSubAccountException.java	2000/06/11 22:30:43	1.3
+++ SOXSubAccountException.java	2000/07/14 00:02:31	1.4
@@ -1,5 +1,5 @@
 /*
- * $Id: SOXSubAccountException.java,v 1.3 2000/06/11 22:30:43 iang Exp $
+ * $Id: SOXSubAccountException.java,v 1.4 2000/07/14 00:02:31 iang Exp $
  *
  * Copyright (c) Systemics Ltd 1995-1999 on behalf of
  * the WebFunds Development Team.  All Rights Reserved.
@@ -21,12 +21,14 @@
     public static final int   FROZEN         = -2,
                               SERVER_DOWN    = -3,
                               NO_SERVER      = -4,
-                              BAD_PACKET     = -5;
+                              BAD_PACKET     = -5,
+                              NO_CONTRACT    = -6;
 
     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 boolean isNoContract()       { return (number == NO_CONTRACT); }
 
     public SOXSubAccountException(String msg)
     {



1.24      +5 -1      java/webfunds/sox/SubAccount.java

Index: SubAccount.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/sox/SubAccount.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- SubAccount.java	2000/07/13 22:50:36	1.23
+++ SubAccount.java	2000/07/14 00:02:31	1.24
@@ -1,4 +1,4 @@
-/* $Id: SubAccount.java,v 1.23 2000/07/13 22:50:36 gelderen Exp $
+/* $Id: SubAccount.java,v 1.24 2000/07/14 00:02:31 iang Exp $
  *
  * Copyright (c) Systemics Inc. 1995-2000 on behalf of
  * The WebFunds Development Team.  All Rights Reserved.
@@ -124,6 +124,10 @@
         try {
             issuer = acct.getIssuer(itemId);
         } catch (SOXIssuerException ex) {
+            if (ex.isNoContract())
+                throw new SOXSubAccountException(
+                      SOXSubAccountException.NO_CONTRACT, ex.getMessage());
+
             throw new SOXSubAccountException(SOXSubAccountException.NO_SERVER,
                       "no SOX server available for " + itemId + " : " + ex);
         }