aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/fs4/ErrorPacket.java
diff options
context:
space:
mode:
Diffstat (limited to 'container-search/src/main/java/com/yahoo/fs4/ErrorPacket.java')
-rw-r--r--container-search/src/main/java/com/yahoo/fs4/ErrorPacket.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/container-search/src/main/java/com/yahoo/fs4/ErrorPacket.java b/container-search/src/main/java/com/yahoo/fs4/ErrorPacket.java
new file mode 100644
index 00000000000..f21663272d4
--- /dev/null
+++ b/container-search/src/main/java/com/yahoo/fs4/ErrorPacket.java
@@ -0,0 +1,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 + ")");
+ }
+
+}