[Webfunds-commits] java/webfunds/ricardian Contract.java
Ian Grigg
iang@cypherpunks.ai
Sat, 30 Sep 2000 14:21:11 -0400 (AST)
iang 00/09/30 14:21:11
Modified: webfunds/ricardian Contract.java
Log:
minor, better management of exceptions
Revision Changes Path
1.45 +33 -11 java/webfunds/ricardian/Contract.java
Index: Contract.java
===================================================================
RCS file: /home/webfunds/cvsroot/java/webfunds/ricardian/Contract.java,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- Contract.java 2000/09/24 23:12:08 1.44
+++ Contract.java 2000/09/30 18:21:11 1.45
@@ -1,4 +1,4 @@
-/* $Id: Contract.java,v 1.44 2000/09/24 23:12:08 iang Exp $
+/* $Id: Contract.java,v 1.45 2000/09/30 18:21:11 iang Exp $
*
* Copyright (c) Systemics Ltd 1995-1999 on behalf of
* the WebFunds Development Team. All Rights Reserved.
@@ -519,8 +519,6 @@
throws ContractException
{
byte[] contractData;
- byte[] localData;
- byte[] userData;
//
// Problem with shoving this out is knowing how the
@@ -528,32 +526,56 @@
//
String root = getRoot(contractfile.toString());
+ File contractfile2 = new File(root + ".asc");
try
{
// Read contractfile
- File contractfile2 = new File(root + ".asc");
FileInputStream fis = new FileInputStream(contractfile2);
contractData = new byte[fis.available()];
fis.read(contractData);
+ }
+ catch (FileNotFoundException ex)
+ {
+ throw new ContractException(ContractException.FILE_ERROR,
+ "no such file "+contractfile+"\n" + ex);
+ }
+ catch (IOException ex)
+ {
+ ex.printStackTrace(System.err);
+ throw new ContractException(ContractException.FILE_ERROR,
+ "cannot read "+contractfile+"\n" + ex);
+ }
+ byte[] localData = new byte[0];
+ File locfile = new File(root + ".loc");
+ try
+ {
// Read localfile
- File locfile = new File(root + ".loc");
- localData = new byte[0];
if (locfile.exists() && locfile.canRead())
{
- fis = new FileInputStream(locfile);
+ FileInputStream fis = new FileInputStream(locfile);
localData = new byte[fis.available()];
fis.read(localData);
}
+ }
+ catch (IOException ex)
+ {
+ ex.printStackTrace(System.err);
+ throw new ContractException(ContractException.FILE_ERROR,
+ "cannot read "+locfile+"\n" + ex);
+ }
+
+ byte[] userData = new byte[0];
+ File myfile = new File(root + ".fuz");
+ try
+ {
// Read my file
- File myfile = new File(root + ".fuz");
- userData = new byte[0];
if (myfile.exists() && myfile.canRead())
{
- fis = new FileInputStream(myfile);
+ FileInputStream fis = new FileInputStream(myfile);
userData = new byte[fis.available()];
fis.read(userData);
}
@@ -562,7 +584,7 @@
{
ex.printStackTrace(System.err);
throw new ContractException(ContractException.FILE_ERROR,
- "cannot read "+contractfile+"\n" + ex);
+ "cannot read "+myfile+"\n" + ex);
}
return getContract(contractData, localData, userData) ;