blob: a74dcb23030619b85e4345191697b594cf262174 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jrt;
import java.nio.ByteBuffer;
class ErrorPacket extends Packet
{
private int errorCode;
private StringValue errorMessage;
public ErrorPacket(int flags, int reqId,
int errorCode,
String errorMessage)
{
super(flags, reqId);
this.errorCode = errorCode;
this.errorMessage = new StringValue(errorMessage);
}
public ErrorPacket(int flags, int reqId,
ByteBuffer src)
{
super(flags, reqId);
errorCode = src.getInt();
errorMessage = new StringValue(src);
}
public int bytes() {
return (headerLength +
4 +
errorMessage.bytes());
}
public int packetCode() {
return PCODE_ERROR;
}
public void encode(ByteBuffer dst) {
dst.putInt(errorCode);
errorMessage.encode(dst);
}
public int errorCode() {
return errorCode;
}
public String errorMessage() {
return errorMessage.asString();
}
}
|