[Webfunds-commits] java/webfunds/ricardian StripKeyException.java
Ian Grigg
iang@cypherpunks.ai
Sun, 27 Aug 2000 17:57:26 -0400 (AST)
iang 00/08/27 17:57:25
Modified: webfunds/ricardian StripKeyException.java
Log:
Now has a bunch of numbers so can indicate what the reason was.
String is quite adequate for sole error printing, in general.
Revision Changes Path
1.2 +63 -4 java/webfunds/ricardian/StripKeyException.java
Index: StripKeyException.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/ricardian/StripKeyException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- StripKeyException.java 2000/08/15 01:52:41 1.1
+++ StripKeyException.java 2000/08/27 21:57:25 1.2
@@ -1,10 +1,69 @@
-
+/*
+ * $Id: StripKeyException.java,v 1.2 2000/08/27 21:57:25 iang Exp $
+ *
+ * Copyright (c) 2000 Systemics Inc on behalf of
+ * the WebFunds Development Team. All Rights Reserved.
+ */
package webfunds.ricardian;
+public class StripKeyException
+ extends Exception
+{
+ /**
+ * Known Contract failure modes detected.
+ */
+ public static final int UNKNOWN = 0,
+ CATCH_ALL = 1, // catch all for other errors
+ NOT_SELF_SIGNED = 2, // no selfsig on key
+ TOO_MANY_SELFS = 3, // too many selfsigs on key?
+ NOT_SIGNED = 4, // not signed by additional
+ TOO_MANY_SIGS = 5, // too many sigs on key?
+ NO_SUCH_USERID = 6, // that userId not there
+ TOO_MANY_USERID = 7; // too many matching userIds
+
+ public static final String[] errors = {
+ "<not set, old Ex>",
+ "'miscellaneous error'",
+ "No SelfSig On Key",
+ "Too Many SelfSigs?",
+ "Not Signed by Signer",
+ "Too Many Sigs By Signer?",
+ "Not Fit For Purpose, No UserId",
+ "Too Many UserIds For Matching",
+ };
+
+
+ /**
+ * What error number has been set by the thrower.
+ */
+ protected int errno = UNKNOWN;
+ public int getErrno() { return errno; }
+
+ public String getErrnoString()
+ {
+ if (! (0 <= errno && errno < errors.length) )
+ return "<invalid: " + errno + ">";
-public final class StripKeyException extends Exception {
+ String e = errors[errno];
- public StripKeyException(String msg) {
- super(msg);
+ return "(" + errno + ") " + ((e == null) ? "'unknown'" : e);
}
+
+ public String toString()
+ {
+ String s = "";
+ if (errno > 0)
+ s += getErrnoString() + ": ";
+ s += super.toString();
+ return s;
+ }
+
+
+ public StripKeyException() { super(); }
+ /** @param msg string interpretation */
+ public StripKeyException(String msg) { super(msg); }
+ /** @param errno an identified error from public constants above */
+ public StripKeyException(int errno) { super(); this.errno = errno; }
+ public StripKeyException(int e, String m) { super(m); this.errno = e; }
+
}