diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
commit | 72231250ed81e10d66bfe70701e64fa5fe50f712 (patch) | |
tree | 2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /jrt/src/com/yahoo/jrt/ErrorPacket.java |
Publish
Diffstat (limited to 'jrt/src/com/yahoo/jrt/ErrorPacket.java')
-rw-r--r-- | jrt/src/com/yahoo/jrt/ErrorPacket.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/jrt/src/com/yahoo/jrt/ErrorPacket.java b/jrt/src/com/yahoo/jrt/ErrorPacket.java new file mode 100644 index 00000000000..fa0ac835826 --- /dev/null +++ b/jrt/src/com/yahoo/jrt/ErrorPacket.java @@ -0,0 +1,52 @@ +// Copyright 2016 Yahoo Inc. 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(); + } +} |