mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-07 02:45:22 +00:00
THRIFT-4609 keep InnerException wherever appropriate
Client: C# Patch: Jens Geyer This closes #1576
This commit is contained in:
parent
831819c563
commit
6e67faa928
@ -859,19 +859,21 @@ namespace Thrift.Protocol
|
||||
{
|
||||
ReadJSONSyntaxChar(QUOTE);
|
||||
}
|
||||
|
||||
string str = ReadJSONNumericChars();
|
||||
if (context.EscapeNumbers())
|
||||
{
|
||||
ReadJSONSyntaxChar(QUOTE);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return Int64.Parse(str);
|
||||
}
|
||||
catch (FormatException)
|
||||
catch (FormatException fex)
|
||||
{
|
||||
throw new TProtocolException(TProtocolException.INVALID_DATA,
|
||||
"Bad data encounted in numeric data");
|
||||
"Bad data encounted in numeric data", fex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -887,8 +889,7 @@ namespace Thrift.Protocol
|
||||
byte[] arr = ReadJSONString(true);
|
||||
double dub = Double.Parse(utf8Encoding.GetString(arr, 0, arr.Length), CultureInfo.InvariantCulture);
|
||||
|
||||
if (!context.EscapeNumbers() && !Double.IsNaN(dub) &&
|
||||
!Double.IsInfinity(dub))
|
||||
if (!context.EscapeNumbers() && !Double.IsNaN(dub) && !Double.IsInfinity(dub))
|
||||
{
|
||||
// Throw exception -- we should not be in a string in this case
|
||||
throw new TProtocolException(TProtocolException.INVALID_DATA,
|
||||
@ -907,10 +908,10 @@ namespace Thrift.Protocol
|
||||
{
|
||||
return Double.Parse(ReadJSONNumericChars(), CultureInfo.InvariantCulture);
|
||||
}
|
||||
catch (FormatException)
|
||||
catch (FormatException fex)
|
||||
{
|
||||
throw new TProtocolException(TProtocolException.INVALID_DATA,
|
||||
"Bad data encounted in numeric data");
|
||||
"Bad data encounted in numeric data", fex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,14 +48,14 @@ namespace Thrift.Protocol
|
||||
type_ = type;
|
||||
}
|
||||
|
||||
public TProtocolException(int type, string message)
|
||||
: base(message)
|
||||
public TProtocolException(int type, string message, Exception inner = null)
|
||||
: base(message, inner)
|
||||
{
|
||||
type_ = type;
|
||||
}
|
||||
|
||||
public TProtocolException(string message)
|
||||
: base(message)
|
||||
public TProtocolException(string message, Exception inner = null)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ namespace Thrift
|
||||
}
|
||||
|
||||
public TApplicationException(ExceptionType type, string message)
|
||||
: base(message)
|
||||
: base(message, null) // TApplicationException is serializable, but we never serialize InnerException
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ namespace Thrift
|
||||
{
|
||||
}
|
||||
|
||||
public TException(string message)
|
||||
: base(message)
|
||||
public TException(string message, Exception inner)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ namespace Thrift.Transport
|
||||
}
|
||||
catch (IOException iox)
|
||||
{
|
||||
throw new TTransportException(TTransportException.ExceptionType.Unknown, iox.ToString());
|
||||
throw new TTransportException(TTransportException.ExceptionType.Unknown, iox.ToString(), iox);
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,11 +217,11 @@ namespace Thrift.Transport
|
||||
}
|
||||
catch (IOException iox)
|
||||
{
|
||||
throw new TTransportException(TTransportException.ExceptionType.Unknown, iox.ToString());
|
||||
throw new TTransportException(TTransportException.ExceptionType.Unknown, iox.ToString(), iox);
|
||||
}
|
||||
catch (WebException wx)
|
||||
{
|
||||
throw new TTransportException(TTransportException.ExceptionType.Unknown, "Couldn't connect to server: " + wx);
|
||||
throw new TTransportException(TTransportException.ExceptionType.Unknown, "Couldn't connect to server: " + wx, wx);
|
||||
}
|
||||
}
|
||||
|
||||
@ -316,7 +316,7 @@ namespace Thrift.Transport
|
||||
}
|
||||
catch (IOException iox)
|
||||
{
|
||||
throw new TTransportException(iox.ToString());
|
||||
throw new TTransportException(iox.ToString(), iox);
|
||||
}
|
||||
}
|
||||
|
||||
@ -360,7 +360,7 @@ namespace Thrift.Transport
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
flushAsyncResult.AsyncException = new TTransportException(exception.ToString());
|
||||
flushAsyncResult.AsyncException = new TTransportException(exception.ToString(), exception);
|
||||
flushAsyncResult.UpdateStatusToComplete();
|
||||
flushAsyncResult.NotifyCallbackWhenAvailable();
|
||||
}
|
||||
@ -375,7 +375,7 @@ namespace Thrift.Transport
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
flushAsyncResult.AsyncException = new TTransportException(exception.ToString());
|
||||
flushAsyncResult.AsyncException = new TTransportException(exception.ToString(), exception);
|
||||
}
|
||||
flushAsyncResult.UpdateStatusToComplete();
|
||||
flushAsyncResult.NotifyCallbackWhenAvailable();
|
||||
|
@ -130,7 +130,7 @@ namespace Thrift.Transport
|
||||
if (stream != null)
|
||||
eOuter = e;
|
||||
else
|
||||
eOuter = new TTransportException(TTransportException.ExceptionType.Interrupted, e.Message);
|
||||
eOuter = new TTransportException(TTransportException.ExceptionType.Interrupted, e.Message, e);
|
||||
}
|
||||
evt.Set();
|
||||
}, null);
|
||||
@ -157,7 +157,7 @@ namespace Thrift.Transport
|
||||
catch (Exception e)
|
||||
{
|
||||
Close();
|
||||
throw new TTransportException(TTransportException.ExceptionType.NotOpen, e.Message);
|
||||
throw new TTransportException(TTransportException.ExceptionType.NotOpen, e.Message, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ namespace Thrift.Transport
|
||||
if (stream != null)
|
||||
eOuter = e;
|
||||
else
|
||||
eOuter = new TTransportException(TTransportException.ExceptionType.Interrupted, e.Message);
|
||||
eOuter = new TTransportException(TTransportException.ExceptionType.Interrupted, e.Message, e);
|
||||
}
|
||||
evt.Set();
|
||||
}, null);
|
||||
@ -265,7 +265,7 @@ namespace Thrift.Transport
|
||||
if (stream != null)
|
||||
eOuter = e;
|
||||
else
|
||||
eOuter = new TTransportException(TTransportException.ExceptionType.Interrupted, e.Message);
|
||||
eOuter = new TTransportException(TTransportException.ExceptionType.Interrupted, e.Message, e);
|
||||
}
|
||||
evt.Set();
|
||||
}, null);
|
||||
|
@ -93,10 +93,10 @@ namespace Thrift.Transport
|
||||
this.server = TSocketVersionizer.CreateTcpListener(this.port);
|
||||
this.server.Server.NoDelay = true;
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
server = null;
|
||||
throw new TTransportException("Could not create ServerSocket on port " + this.port + ".");
|
||||
throw new TTransportException("Could not create ServerSocket on port " + this.port + ".", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ namespace Thrift.Transport
|
||||
}
|
||||
catch (SocketException sx)
|
||||
{
|
||||
throw new TTransportException("Could not accept on listening socket: " + sx.Message);
|
||||
throw new TTransportException("Could not accept on listening socket: " + sx.Message, sx);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -153,7 +153,7 @@ namespace Thrift.Transport
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new TTransportException(ex.ToString());
|
||||
throw new TTransportException(ex.ToString(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ namespace Thrift.Transport
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new TTransportException("WARNING: Could not close server socket: " + ex);
|
||||
throw new TTransportException("WARNING: Could not close server socket: " + ex, ex);
|
||||
}
|
||||
server = null;
|
||||
}
|
||||
|
@ -129,10 +129,10 @@ namespace Thrift.Transport
|
||||
this.server = TSocketVersionizer.CreateTcpListener(this.port);
|
||||
this.server.Server.NoDelay = true;
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
server = null;
|
||||
throw new TTransportException("Could not create ServerSocket on port " + this.port + ".");
|
||||
throw new TTransportException("Could not create ServerSocket on port " + this.port + ".", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ namespace Thrift.Transport
|
||||
}
|
||||
catch (SocketException sx)
|
||||
{
|
||||
throw new TTransportException("Could not accept on listening socket: " + sx.Message);
|
||||
throw new TTransportException("Could not accept on listening socket: " + sx.Message, sx);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -197,7 +197,7 @@ namespace Thrift.Transport
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new TTransportException(ex.ToString());
|
||||
throw new TTransportException(ex.ToString(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ namespace Thrift.Transport
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new TTransportException("WARNING: Could not close server socket: " + ex);
|
||||
throw new TTransportException("WARNING: Could not close server socket: " + ex, ex);
|
||||
}
|
||||
this.server = null;
|
||||
}
|
||||
|
@ -40,14 +40,14 @@ namespace Thrift.Transport
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public TTransportException(ExceptionType type, string message)
|
||||
: base(message)
|
||||
public TTransportException(ExceptionType type, string message, Exception inner = null)
|
||||
: base(message, inner)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public TTransportException(string message)
|
||||
: base(message)
|
||||
public TTransportException(string message, Exception inner = null)
|
||||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user