Browse Source

Json exception handling. #198

master
Nikita 10 years ago
parent
commit
54a8fbb7d5
  1. 5
      src/main/java/com/corundumstudio/socketio/JsonSupportWrapper.java
  2. 2
      src/main/java/com/corundumstudio/socketio/handler/InPacketHandler.java
  3. 10
      src/main/java/com/corundumstudio/socketio/listener/DefaultExceptionListener.java
  4. 4
      src/main/java/com/corundumstudio/socketio/listener/ExceptionListener.java
  5. 8
      src/main/java/com/corundumstudio/socketio/listener/ExceptionListenerAdapter.java
  6. 27
      src/main/java/com/corundumstudio/socketio/protocol/DecoderException.java

5
src/main/java/com/corundumstudio/socketio/JsonSupportWrapper.java

@ -43,7 +43,7 @@ class JsonSupportWrapper implements JsonSupport {
} catch (Exception e) {
src.reset();
log.error("Can't read ack args: " + src.readLine() + " for type: " + callback.getResultClass(), e);
return null;
throw new IOException(e);
}
}
@ -53,7 +53,7 @@ class JsonSupportWrapper implements JsonSupport {
} catch (Exception e) {
src.reset();
log.error("Can't read value: " + src.readLine() + " for type: " + valueType, e);
return null;
throw new IOException(e);
}
}
@ -62,6 +62,7 @@ class JsonSupportWrapper implements JsonSupport {
delegate.writeValue(out, value);
} catch (Exception e) {
log.error("Can't write value: " + value, e);
throw new IOException(e);
}
}

2
src/main/java/com/corundumstudio/socketio/handler/InPacketHandler.java

@ -93,7 +93,7 @@ public class InPacketHandler extends SimpleChannelInboundHandler<PacketsMessage>
} catch (Exception ex) {
String c = content.toString(CharsetUtil.UTF_8);
log.error("Error during data processing. Client sessionId: " + client.getSessionId() + ", data: " + c, ex);
return;
throw ex;
}
}
}

10
src/main/java/com/corundumstudio/socketio/listener/DefaultExceptionListener.java

@ -43,16 +43,6 @@ public class DefaultExceptionListener extends ExceptionListenerAdapter {
log.error(e.getMessage(), e);
}
@Override
public void onMessageException(Exception e, String data, SocketIOClient client) {
log.error(e.getMessage(), e);
}
@Override
public void onJsonException(Exception e, Object data, SocketIOClient client) {
log.error(e.getMessage(), e);
}
public boolean exceptionCaught(ChannelHandlerContext ctx, Throwable e) throws Exception {
log.error(e.getMessage(), e);
return true;

4
src/main/java/com/corundumstudio/socketio/listener/ExceptionListener.java

@ -29,10 +29,6 @@ public interface ExceptionListener {
void onConnectException(Exception e, SocketIOClient client);
void onMessageException(Exception e, String data, SocketIOClient client);
void onJsonException(Exception e, Object data, SocketIOClient client);
boolean exceptionCaught(ChannelHandlerContext ctx, Throwable e) throws Exception;
}

8
src/main/java/com/corundumstudio/socketio/listener/ExceptionListenerAdapter.java

@ -40,14 +40,6 @@ public abstract class ExceptionListenerAdapter implements ExceptionListener {
public void onConnectException(Exception e, SocketIOClient client) {
}
@Override
public void onMessageException(Exception e, String data, SocketIOClient client) {
}
@Override
public void onJsonException(Exception e, Object data, SocketIOClient client) {
}
@Override
public boolean exceptionCaught(ChannelHandlerContext ctx, Throwable e) throws Exception {
return false;

27
src/main/java/com/corundumstudio/socketio/protocol/DecoderException.java

@ -1,27 +0,0 @@
/**
* Copyright 2012 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.corundumstudio.socketio.protocol;
// TODO use SocketIOException
public class DecoderException extends RuntimeException {
private static final long serialVersionUID = -312474299994609579L;
public DecoderException(String message) {
super(message);
}
}
Loading…
Cancel
Save