Search in sources :

Example 1 with ReplyFailure

use of io.vertx.core.eventbus.ReplyFailure in project chili-core by codingchili.

the class BusRouter method send.

protected void send(Request request, String target) {
    DeliveryOptions options = new DeliveryOptions().setSendTimeout(request.timeout());
    core.bus().send(target, request.data(), options, send -> {
        if (send.succeeded()) {
            request.write(send.result().body());
        } else {
            Throwable exception = send.cause();
            if (exception instanceof ReplyException) {
                ReplyFailure status = ((ReplyException) exception).failureType();
                exceptionHandlers.get(status).accept(request);
            } else {
                request.error(send.cause());
            }
        }
    });
}
Also used : ReplyFailure(io.vertx.core.eventbus.ReplyFailure) DeliveryOptions(io.vertx.core.eventbus.DeliveryOptions) ReplyException(io.vertx.core.eventbus.ReplyException)

Example 2 with ReplyFailure

use of io.vertx.core.eventbus.ReplyFailure in project vert.x by eclipse.

the class ReplyExceptionMessageCodec method decodeFromWire.

@Override
public ReplyException decodeFromWire(int pos, Buffer buffer) {
    int i = (int) buffer.getByte(pos);
    ReplyFailure rf = ReplyFailure.fromInt(i);
    pos++;
    int failureCode = buffer.getInt(pos);
    pos += 4;
    boolean isNull = buffer.getByte(pos) == (byte) 0;
    String message;
    if (!isNull) {
        pos++;
        int strLength = buffer.getInt(pos);
        pos += 4;
        byte[] bytes = buffer.getBytes(pos, pos + strLength);
        message = new String(bytes, CharsetUtil.UTF_8);
    } else {
        message = null;
    }
    return new ReplyException(rf, failureCode, message);
}
Also used : ReplyFailure(io.vertx.core.eventbus.ReplyFailure) ReplyException(io.vertx.core.eventbus.ReplyException)

Aggregations

ReplyException (io.vertx.core.eventbus.ReplyException)2 ReplyFailure (io.vertx.core.eventbus.ReplyFailure)2 DeliveryOptions (io.vertx.core.eventbus.DeliveryOptions)1