All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.tarantool.driver.protocol.TarantoolErrorResult Maven / Gradle / Ivy

Go to download

Tarantool Cartridge driver for Tarantool versions 1.10+ based on Netty framework

There is a newer version: 0.14.0
Show newest version
package io.tarantool.driver.protocol;

import org.msgpack.value.Value;

/**
 * Incapsulates the error data returned in Tarantool server response
 *
 * @author Alexey Kuzin
 */
public class TarantoolErrorResult {

    private final Long syncId;
    private final Long errorCode;
    private final String errorMessage;

    /**
     * Basic constructor.
     * @param syncId the request ID passed back from Tarantool server
     * @param errorCode error status code
     * @param body response body containing the error message
     * @throws TarantoolProtocolException if the specified body is invalid
     */
    public TarantoolErrorResult(Long syncId, Long errorCode, Value body) throws TarantoolProtocolException {
        this.syncId = syncId;
        this.errorCode = errorCode;
        if (!body.isStringValue()) {
            throw new TarantoolProtocolException("Error body is not a MP_STRING value: {}", body.toJson());
        }
        this.errorMessage = body.asStringValue().toString();
    }

    /**
     * Get request ID a.k.a. sync ID
     * @return a number
     */
    public Long getSyncId() {
        return syncId;
    }

    /**
     * Get error status code
     * @return a number
     * @see "https://github.com/tarantool/tarantool/blob/master/src/box/errcode.h"
     */
    public Long getErrorCode() {
        return errorCode;
    }

    /**
     * Get error message
     * @return message
     */
    public String getErrorMessage() {
        return errorMessage;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy