This is an automated email from the ASF dual-hosted git repository. jensg pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/thrift.git
The following commit(s) were added to refs/heads/master by this push: new 6e67faa THRIFT-4609 keep InnerException wherever appropriate Client: C# Patch: Jens Geyer 6e67faa is described below commit 6e67faa92827ece022380b211c2caaadd6145bf5 Author: Jens Geyer <je...@apache.org> AuthorDate: Mon Aug 6 23:31:38 2018 +0200 THRIFT-4609 keep InnerException wherever appropriate Client: C# Patch: Jens Geyer This closes #1576 --- lib/csharp/src/Protocol/TJSONProtocol.cs | 13 +++++++------ lib/csharp/src/Protocol/TProtocolException.cs | 8 ++++---- lib/csharp/src/TApplicationException.cs | 2 +- lib/csharp/src/TException.cs | 4 ++-- lib/csharp/src/Transport/THttpClient.cs | 12 ++++++------ lib/csharp/src/Transport/TNamedPipeServerTransport.cs | 8 ++++---- lib/csharp/src/Transport/TServerSocket.cs | 10 +++++----- lib/csharp/src/Transport/TTLSServerSocket.cs | 10 +++++----- lib/csharp/src/Transport/TTransportException.cs | 8 ++++---- 9 files changed, 38 insertions(+), 37 deletions(-) diff --git a/lib/csharp/src/Protocol/TJSONProtocol.cs b/lib/csharp/src/Protocol/TJSONProtocol.cs index 3390dc0..9dbdea9 100644 --- a/lib/csharp/src/Protocol/TJSONProtocol.cs +++ b/lib/csharp/src/Protocol/TJSONProtocol.cs @@ -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); } } } diff --git a/lib/csharp/src/Protocol/TProtocolException.cs b/lib/csharp/src/Protocol/TProtocolException.cs index a89c3fc..c0f007e 100644 --- a/lib/csharp/src/Protocol/TProtocolException.cs +++ b/lib/csharp/src/Protocol/TProtocolException.cs @@ -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) { } diff --git a/lib/csharp/src/TApplicationException.cs b/lib/csharp/src/TApplicationException.cs index 0c5b08b..8dd7ae5 100644 --- a/lib/csharp/src/TApplicationException.cs +++ b/lib/csharp/src/TApplicationException.cs @@ -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; } diff --git a/lib/csharp/src/TException.cs b/lib/csharp/src/TException.cs index 35193c5..aa9a210 100644 --- a/lib/csharp/src/TException.cs +++ b/lib/csharp/src/TException.cs @@ -31,8 +31,8 @@ namespace Thrift { } - public TException(string message) - : base(message) + public TException(string message, Exception inner) + : base(message, inner) { } diff --git a/lib/csharp/src/Transport/THttpClient.cs b/lib/csharp/src/Transport/THttpClient.cs index 06ed6bc..667fc25 100644 --- a/lib/csharp/src/Transport/THttpClient.cs +++ b/lib/csharp/src/Transport/THttpClient.cs @@ -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(); diff --git a/lib/csharp/src/Transport/TNamedPipeServerTransport.cs b/lib/csharp/src/Transport/TNamedPipeServerTransport.cs index a6cfb2e..32215cf 100644 --- a/lib/csharp/src/Transport/TNamedPipeServerTransport.cs +++ b/lib/csharp/src/Transport/TNamedPipeServerTransport.cs @@ -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); diff --git a/lib/csharp/src/Transport/TServerSocket.cs b/lib/csharp/src/Transport/TServerSocket.cs index 40e47dc..d8ec62a 100644 --- a/lib/csharp/src/Transport/TServerSocket.cs +++ b/lib/csharp/src/Transport/TServerSocket.cs @@ -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; } diff --git a/lib/csharp/src/Transport/TTLSServerSocket.cs b/lib/csharp/src/Transport/TTLSServerSocket.cs index aa8ff7c..716a97c 100644 --- a/lib/csharp/src/Transport/TTLSServerSocket.cs +++ b/lib/csharp/src/Transport/TTLSServerSocket.cs @@ -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; } diff --git a/lib/csharp/src/Transport/TTransportException.cs b/lib/csharp/src/Transport/TTransportException.cs index ae987d5..7f6cc18 100644 --- a/lib/csharp/src/Transport/TTransportException.cs +++ b/lib/csharp/src/Transport/TTransportException.cs @@ -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) { }