EngineIOException

This commit is contained in:
Naoyuki Kanezawa
2013-04-22 22:44:01 +09:00
parent f60105ada0
commit bcff9c0d9a
5 changed files with 30 additions and 28 deletions

View File

@@ -88,6 +88,7 @@ public class Emitter {
}
public static interface Listener {
public void call(Object... args);
}
}

View File

@@ -0,0 +1,20 @@
package com.github.nkzawa.engineio.client;
public class EngineIOException extends Exception {
public EngineIOException() {
super();
}
public EngineIOException(String message) {
super(message);
}
public EngineIOException(String message, Throwable cause) {
super(message, cause);
}
public EngineIOException(Throwable cause) {
super(cause);
}
}

View File

@@ -188,8 +188,8 @@ public abstract class Socket extends Emitter {
// TODO: handle error
Exception err = args.length > 0 ? (Exception)args[0] : null;
Transport.TransportException error = new Transport.TransportException("probe error", err);
error.transport = transport[0].name;
EngineIOException error = new EngineIOException("probe error", err);
//error.transport = transport[0].name;
transport[0].close();
transport[0] = null;
@@ -239,8 +239,8 @@ public abstract class Socket extends Emitter {
});
} else {
logger.info(String.format("probe transport '%s' failed", name));
Transport.TransportException err = new Transport.TransportException("probe error");
err.transport = transport[0].name;
EngineIOException err = new EngineIOException("probe error");
//err.transport = transport[0].name;
self.emit("error", err);
}
}
@@ -305,8 +305,8 @@ public abstract class Socket extends Emitter {
this.ping();
} else if ("error".equals(packet.type)) {
// TODO: handle error
Exception err = new Exception("server error");
// err.code = packet.data;
EngineIOException err = new EngineIOException("server error");
//err.code = packet.data;
this.emit("error", err);
} else if ("message".equals(packet.type)) {
this.emit("data", packet.data);
@@ -491,7 +491,7 @@ public abstract class Socket extends Emitter {
this.onclose();
// TODO:
// clean buffer in next tick, so developers can still
// gra the buffers on `close` event
// grab the buffers on `close` event
// setTimeout(function() {}
// self.writeBuffer = [];
// self.callbackBuffer = [];

View File

@@ -22,9 +22,6 @@ public abstract class Transport extends Emitter {
protected String timestampParam;
protected String readyState = "";
public Transport() {
// TODO: remove
}
public Transport(Options opts) {
this.path = opts.path;
@@ -37,10 +34,8 @@ public abstract class Transport extends Emitter {
}
protected Transport onError(String msg, Exception desc) {
// TODO:
Exception err = new Exception(msg);
// err.type = "TransportError";
// err.description = desc;
// TODO: handle error
Exception err = new EngineIOException(msg, desc);
this.emit("error", err);
return this;
}
@@ -107,17 +102,4 @@ public abstract class Transport extends Emitter {
public List<NameValuePair> query;
}
public static class TransportException extends Exception {
public String transport;
public TransportException(String detailMessage) {
super(detailMessage);
}
public TransportException(String detailMessage, Throwable throwable) {
super(detailMessage, throwable);
}
}
}

View File

@@ -123,7 +123,6 @@ public class PollingXHR extends Polling {
}
this.onData(data.toString());
} catch (IOException e) {
e.printStackTrace();
this.onError(e);
} finally {
try {