org.opendaylight.groupbasedpolicy.jsonrpc.ExceptionHandler.java Source code

Java tutorial

Introduction

Here is the source code for org.opendaylight.groupbasedpolicy.jsonrpc.ExceptionHandler.java

Source

/*
 * Copyright (C) 2013 EBay Software Foundation
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 *
 * Authors : Ashwin Raveendran
 */
package org.opendaylight.groupbasedpolicy.jsonrpc;

import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.TooLongFrameException;

public class ExceptionHandler extends ChannelHandlerAdapter {

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        if ((cause instanceof InvalidEncodingException) || (cause instanceof TooLongFrameException)) {

            ctx.channel().disconnect();
        }
    }
}