Browse Source

Use standard exceptions

nxrighthere 7 years ago
parent
commit
b4926569df
1 changed files with 3 additions and 13 deletions
  1. 3 13
      Source/Managed/ENet.cs

+ 3 - 13
Source/Managed/ENet.cs

@@ -409,7 +409,7 @@ namespace ENet {
 			}
 			}
 
 
 			if (nativeHost == IntPtr.Zero)
 			if (nativeHost == IntPtr.Zero)
-				throw new ENetException(0, "Host creation call failed");
+				throw new InvalidOperationException("Host creation call failed");
 		}
 		}
 
 
 		public void Broadcast(byte channelID, ref Packet packet) {
 		public void Broadcast(byte channelID, ref Packet packet) {
@@ -454,7 +454,7 @@ namespace ENet {
 			var peer = new Peer(Native.enet_host_connect(nativeHost, ref nativeAddress, (IntPtr)channelLimit, data));
 			var peer = new Peer(Native.enet_host_connect(nativeHost, ref nativeAddress, (IntPtr)channelLimit, data));
 
 
 			if (peer.NativeData == IntPtr.Zero)
 			if (peer.NativeData == IntPtr.Zero)
-				throw new ENetException(0, "Host connect call failed");
+				throw new InvalidOperationException("Host connect call failed");
 
 
 			return peer;
 			return peer;
 		}
 		}
@@ -676,16 +676,6 @@ namespace ENet {
 		}
 		}
 	}
 	}
 
 
-	public class ENetException : Exception {
-		public ENetException(int code, string message) : base(message) {
-			Code = code;
-		}
-
-		public int Code {
-			get; private set;
-		}
-	}
-
 	public static class Library {
 	public static class Library {
 		public const uint maxChannelCount = 0xFF;
 		public const uint maxChannelCount = 0xFF;
 		public const uint maxPeers = 0xFFF;
 		public const uint maxPeers = 0xFFF;
@@ -862,4 +852,4 @@ namespace ENet {
 		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
 		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
 		internal static extern void enet_peer_reset(IntPtr peer);
 		internal static extern void enet_peer_reset(IntPtr peer);
 	}
 	}
-}
+}