From 115a241807b1e9f7b526c406ff7e9d4dd027ddee Mon Sep 17 00:00:00 2001 From: Joseph Henry Date: Thu, 14 Jan 2021 18:11:30 -0800 Subject: [PATCH] Add ZeroTierException to C# Wrapper for better error reporting --- examples/csharp/Socket.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/examples/csharp/Socket.cs b/examples/csharp/Socket.cs index f50414f..28d1bab 100644 --- a/examples/csharp/Socket.cs +++ b/examples/csharp/Socket.cs @@ -23,6 +23,16 @@ using ZeroTier; /// namespace ZeroTier { + public class ZeroTierException : Exception + { + public ZeroTierException(int _serviceErrorCode, int _socketErrorCode) { + ServiceErrorCode = _serviceErrorCode; + SocketErrorCode = _socketErrorCode; + } + public int ServiceErrorCode { get; set; } + public int SocketErrorCode { get; set; } + } + /// /// ZeroTier Socket - An lwIP socket mediated over a ZeroTier virtual link /// @@ -172,7 +182,7 @@ namespace ZeroTier */ } if (err < 0) { - throw new SocketException((int)err); + throw new ZeroTierException(err, ZeroTier.Node.ErrNo); } _remoteEndPoint = remoteEndPoint; }