[Webfunds-commits] java/webfunds/client/sox CancelException.java DepositException.java WalletException.java
Ian Grigg
iang@cypherpunks.ai
Sun, 16 Jul 2000 15:24:01 -0400 (AST)
iang 00/07/16 15:24:01
Modified: webfunds/client/sox CancelException.java
DepositException.java WalletException.java
Log:
unified and rationalised like SOX*Exception
Revision Changes Path
1.2 +5 -10 java/webfunds/client/sox/CancelException.java
Index: CancelException.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/sox/CancelException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CancelException.java 2000/05/28 02:59:56 1.1
+++ CancelException.java 2000/07/16 19:24:01 1.2
@@ -1,5 +1,5 @@
/*
- * $Id: CancelException.java,v 1.1 2000/05/28 02:59:56 iang Exp $
+ * $Id: CancelException.java,v 1.2 2000/07/16 19:24:01 iang Exp $
*
* Copyright (c) 2000 Systemics Inc on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -7,21 +7,16 @@
package webfunds.client.sox;
/**
- * This exception class is thrown when a cancel call fails.
+ * This exception class is thrown when a cancel call fails.
+ * For hich-level but non-GUI wallet calls.
*/
public class CancelException
extends WalletException
{
- public final static int ALREADY = 1,
- SERVER = 2,
- TOO_LATE = 3, // cannot, already accepted
- INTERNAL = 4;
- public boolean isAlready() { return number == ALREADY ; }
- public boolean isTooLate() { return number == TOO_LATE ; }
- public boolean isFailed() { return number != ALREADY ; }
-
public CancelException(String msg) { super(msg); }
public CancelException(int errno) { super(errno); }
public CancelException(int errno, String msg) { super(errno, msg); }
+
+ public String toString() { return "CanEx: " + super.getMessage(); }
}
1.4 +11 -19 java/webfunds/client/sox/DepositException.java
Index: DepositException.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/sox/DepositException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DepositException.java 2000/06/20 20:04:36 1.3
+++ DepositException.java 2000/07/16 19:24:01 1.4
@@ -1,30 +1,22 @@
-/* $Id: DepositException.java,v 1.3 2000/06/20 20:04:36 gelderen Exp $
+/* $Id: DepositException.java,v 1.4 2000/07/16 19:24:01 iang Exp $
*
* Copyright (c) 2000 Systemics Inc. on behalf of
* The WebFunds Development Team. All rights reserved.
*/
package webfunds.client.sox;
+import webfunds.sox.Errors;
-public final class DepositException extends WalletException
+public final class DepositException
+ extends WalletException
{
- public static final int
- UNKNOWN_ACCOUNT = 1,
- INSUFFICIENT_FUNDS = 2,
- NO_RECEIPT = 3;
- private int code;
+ /**
+ * @param num is a sox code
+ */
+ public DepositException(int num) { super(num); }
+ public DepositException(int num, String s) { super(num, s); }
+ public DepositException(String s) { super(s); }
-
- public int getCode()
- {
- return this.code;
- }
-
-
- public DepositException(int code)
- {
- super("Deposit Failed (" + code + ")");
- this.code = code;
- }
+ public String toString() { return "DepEx: " + super.getMessage(); }
}
1.2 +43 -4 java/webfunds/client/sox/WalletException.java
Index: WalletException.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/client/sox/WalletException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- WalletException.java 2000/05/28 02:59:56 1.1
+++ WalletException.java 2000/07/16 19:24:01 1.2
@@ -1,11 +1,13 @@
/*
- * $Id: WalletException.java,v 1.1 2000/05/28 02:59:56 iang Exp $
+ * $Id: WalletException.java,v 1.2 2000/07/16 19:24:01 iang Exp $
*
* Copyright (c) 2000 Systemics Inc on behalf of
* the WebFunds Development Team. All Rights Reserved.
*/
package webfunds.client.sox;
+import webfunds.sox.Errors;
+
/**
* This exception base class is inherited by all
* internal SOX Wallet Exceptions.
@@ -13,11 +15,48 @@
public class WalletException
extends Exception
{
- public final static int UNKNOWN = 0;
- protected int number;
- public int getNumber() { return number; }
+ private int number;
+ public int getNumber() { return number; }
+
+ /**
+ * These high-level wallet errors are positive and greater than 99,
+ * leaving room for SOXException errors to be negative, and SOX
+ * Errors(.java) to be 0-100.
+ *
+ * This is a lot of overloading!
+ */
+ public final static int UNKNOWN = 100,
+ ALREADY = 101, // this one done already
+ SERVER = 102, // server not there
+ TOO_LATE = 103, // cannot, already accepted
+ INTERNAL = 104, // some code failure
+ UNKNOWN_AC = 105, // cannot access
+ UNKNOWN_SUB = 106, // cannot access
+ NOT_VALUE = 107, // not a ValueAccount
+ NOT_ENUF_FUNDS = 108, // never thrown?
+
+ LAST_WALLET_ERRNO = 108;
+
+ /**
+ * Use these rather than worry about which number...
+ */
+ public boolean isUnknownAccount() { return getNumber() == UNKNOWN_AC; }
+ public boolean isAlready() { return getNumber() == ALREADY ; }
+ public boolean isTooLate() { return getNumber() == TOO_LATE ; }
+
+ public boolean isFailed() { return getNumber() != ALREADY ; }
+ public boolean isNoFunds()
+ {
+ return (number == Errors.ERROR_NO_FUNDS) ||
+ (number == NOT_ENUF_FUNDS);
+ }
+
+
+
public WalletException(String msg) { super(msg); number = 0; }
public WalletException(int num) { super("" ); number = num; }
public WalletException(int num, String msg) { super(msg); number = num; }
+
+ public String toString() { return "("+number+") " + super.getMessage(); }
}