blob: f21663272d4b7ac32c44edf1a56f268e614d1991 (
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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.fs4;
import java.nio.ByteBuffer;
import com.yahoo.text.Utf8;
/**
*
* An error packet signaling that an error occurred.
*
* @author Bjørn Borud
*/
public class ErrorPacket extends Packet {
private int errorCode;
private int errmsgLen;
private String message;
private ErrorPacket() {
}
public static ErrorPacket create() {
return new ErrorPacket();
}
public int getCode() { return 203; }
public void decodeBody(ByteBuffer buffer) {
errorCode = buffer.getInt();
errmsgLen = buffer.getInt();
byte[] tmp = new byte[errmsgLen];
buffer.get(tmp);
message = Utf8.toString(tmp);
}
public int getErrorCode () { return errorCode; }
public void encodeBody(ByteBuffer buffer) {
// No body
}
public String toString() {
return (message + " (" + errorCode + ")");
}
}
|