io.tarantool.driver.protocol.TarantoolErrorResult Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cartridge-driver Show documentation
Show all versions of cartridge-driver Show documentation
Tarantool Cartridge driver for Tarantool versions 1.10+ based on Netty framework
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;
}
}