THRIFT-3361 Improve C# library
Client: C#
Patch: Jens Geyer <jensg@apache.org>
Replaced a bunch of C# exceptions with TTransportException.
diff --git a/lib/csharp/src/Transport/TBufferedTransport.cs b/lib/csharp/src/Transport/TBufferedTransport.cs
index e88800f..caedd87 100644
--- a/lib/csharp/src/Transport/TBufferedTransport.cs
+++ b/lib/csharp/src/Transport/TBufferedTransport.cs
@@ -75,7 +75,7 @@
CheckNotDisposed();
ValidateBufferArgs(buf, off, len);
if (!IsOpen)
- throw new InvalidOperationException("Transport is not open.");
+ throw new TTransportException(TTransportException.ExceptionType.NotOpen);
if (inputBuffer.Capacity < bufSize)
inputBuffer.Capacity = bufSize;
int got = inputBuffer.Read(buf, off, len);
@@ -96,7 +96,7 @@
CheckNotDisposed();
ValidateBufferArgs(buf, off, len);
if (!IsOpen)
- throw new InvalidOperationException("Transport is not open.");
+ throw new TTransportException(TTransportException.ExceptionType.NotOpen);
// Relative offset from "off" argument
int offset = 0;
if (outputBuffer.Length > 0)
@@ -129,7 +129,7 @@
{
CheckNotDisposed();
if (!IsOpen)
- throw new InvalidOperationException("Transport is not open.");
+ throw new TTransportException(TTransportException.ExceptionType.NotOpen);
if (outputBuffer.Length > 0)
{
transport.Write(outputBuffer.GetBuffer(), 0, (int)outputBuffer.Length);
diff --git a/lib/csharp/src/Transport/TFramedTransport.cs b/lib/csharp/src/Transport/TFramedTransport.cs
index 9c6a794..a369e8e 100644
--- a/lib/csharp/src/Transport/TFramedTransport.cs
+++ b/lib/csharp/src/Transport/TFramedTransport.cs
@@ -73,7 +73,7 @@
CheckNotDisposed();
ValidateBufferArgs(buf, off, len);
if (!IsOpen)
- throw new InvalidOperationException("Transport is not open.");
+ throw new TTransportException(TTransportException.ExceptionType.NotOpen);
int got = readBuffer.Read(buf, off, len);
if (got > 0)
{
@@ -102,7 +102,7 @@
CheckNotDisposed();
ValidateBufferArgs(buf, off, len);
if (!IsOpen)
- throw new InvalidOperationException("Transport is not open.");
+ throw new TTransportException(TTransportException.ExceptionType.NotOpen);
if (writeBuffer.Length + (long)len > (long)int.MaxValue)
Flush();
writeBuffer.Write(buf, off, len);
@@ -112,7 +112,7 @@
{
CheckNotDisposed();
if (!IsOpen)
- throw new InvalidOperationException("Transport is not open.");
+ throw new TTransportException(TTransportException.ExceptionType.NotOpen);
byte[] buf = writeBuffer.GetBuffer();
int len = (int)writeBuffer.Length;
int data_len = len - HeaderSize;