public void Receive()
{
Reader = new BinaryReader(Connection.GetNetworkStream());
var reader = Reader;
Status = (ResponseStatus)reader.ReadByte();
SessionId = reader.ReadInt32EndianAware();
if (Status == ResponseStatus.ERROR)
{
string exceptionString = "";
byte followByte = reader.ReadByte();
while (followByte == 1)
{
int exceptionClassLength = reader.ReadInt32EndianAware();
exceptionString += System.Text.Encoding.Default.GetString(reader.ReadBytes(exceptionClassLength)) + ": ";
int exceptionMessageLength = reader.ReadInt32EndianAware();
// don't read exception message string if it's null
if (exceptionMessageLength != -1)
{
exceptionString += System.Text.Encoding.Default.GetString(reader.ReadBytes(exceptionMessageLength)) + "\n";
}
followByte = reader.ReadByte();
}
throw new OException(OExceptionType.Operation, exceptionString);
}
}