Example usage for io.netty.handler.codec DecoderException DecoderException

List of usage examples for io.netty.handler.codec DecoderException DecoderException

Introduction

In this page you can find the example usage for io.netty.handler.codec DecoderException DecoderException.

Prototype

public DecoderException(String message, Throwable cause) 

Source Link

Document

Creates a new instance.

Usage

From source file:cloudfoundry.norouter.f5.dropsonde.LineEventDecoder.java

License:Open Source License

@Override
protected void decode(ChannelHandlerContext context, ByteBuf buffer, List<Object> out) throws Exception {
    buffer.markReaderIndex();//from   w w  w .  java  2 s .  c  o  m
    try {
        final String command = nextString(buffer);
        // Extract event type
        switch (command) {
        case "LOG":
            decodeLogEvent(context, buffer, out);
            break;
        default:
            throw new IllegalStateException("Unknown command " + command);
        }
    } catch (Exception e) {
        buffer.resetReaderIndex();
        throw new DecoderException("Invalid line event: " + buffer.toString(StandardCharsets.UTF_8), e);
    }
}