More work on error propagation and improving log messages in i2ptunnel and I2CP client

This commit is contained in:
zzz
2010-11-19 14:41:26 +00:00
parent e940f51599
commit 4545a98968
14 changed files with 223 additions and 93 deletions

View File

@@ -15,39 +15,28 @@ import java.io.PrintWriter;
/**
* Base class of I2P exceptions
*
* This was originally used to provide chained exceptions, but
* those were added to Exception in Java 1.4, so this class provides nothing
* extra at the moment.
*
* @author jrandom
*/
public class I2PException extends Exception {
private Throwable _source;
public I2PException() {
this(null, null);
super();
}
public I2PException(String msg) {
this(msg, null);
}
public I2PException(String msg, Throwable source) {
super(msg);
_source = source;
}
@Override
public void printStackTrace() {
if (_source != null) _source.printStackTrace();
super.printStackTrace();
}
@Override
public void printStackTrace(PrintStream ps) {
if (_source != null) _source.printStackTrace(ps);
super.printStackTrace(ps);
}
@Override
public void printStackTrace(PrintWriter pw) {
if (_source != null) _source.printStackTrace(pw);
super.printStackTrace(pw);
public I2PException(String msg, Throwable cause) {
super(msg, cause);
}
}
/** @since 0.8.2 */
public I2PException(Throwable cause) {
super(cause);
}
}

View File

@@ -304,7 +304,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
while (!_dateReceived) {
if (waitcount++ > 30) {
closeSocket();
throw new IOException("no date handshake");
throw new IOException("No handshake received from the router");
}
try {
synchronized (_dateReceivedLock) {
@@ -327,7 +327,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
_producer.disconnect(this);
} catch (I2PSessionException ipe) {}
closeSocket();
throw new IOException("no leaseset");
throw new IOException("No tunnels built after waiting 5 minutes... are there network problems?");
}
synchronized (_leaseSetWait) {
try {
@@ -346,11 +346,11 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
} catch (UnknownHostException uhe) {
_closed = true;
setOpening(false);
throw new I2PSessionException(getPrefix() + "Invalid session configuration", uhe);
throw new I2PSessionException(getPrefix() + "Cannot connect to the router on " + _hostname + ':' + _portNum, uhe);
} catch (IOException ioe) {
_closed = true;
setOpening(false);
throw new I2PSessionException(getPrefix() + "Problem connecting to " + _hostname + " on port " + _portNum, ioe);
throw new I2PSessionException(getPrefix() + "Cannot connect to the router on " + _hostname + ':' + _portNum, ioe);
}
}

View File

@@ -86,10 +86,10 @@ class I2PSimpleSession extends I2PSessionImpl2 {
} catch (UnknownHostException uhe) {
_closed = true;
throw new I2PSessionException(getPrefix() + "Bad host ", uhe);
throw new I2PSessionException(getPrefix() + "Cannot connect to the router on " + _hostname + ':' + _portNum, uhe);
} catch (IOException ioe) {
_closed = true;
throw new I2PSessionException(getPrefix() + "Problem connecting to " + _hostname + " on port " + _portNum, ioe);
throw new I2PSessionException(getPrefix() + "Cannot connect to the router on " + _hostname + ':' + _portNum, ioe);
}
}