From d3a8582d92a1002ab9a9315142c5df4e3af78031 Mon Sep 17 00:00:00 2001 From: sta Date: Thu, 16 Mar 2017 17:39:41 +0900 Subject: [PATCH] [Modify] Throw exceptions --- websocket-sharp/Server/WebSocketServiceManager.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Server/WebSocketServiceManager.cs b/websocket-sharp/Server/WebSocketServiceManager.cs index 102ba6f9..e9337f0c 100644 --- a/websocket-sharp/Server/WebSocketServiceManager.cs +++ b/websocket-sharp/Server/WebSocketServiceManager.cs @@ -770,16 +770,19 @@ namespace WebSocketSharp.Server /// public bool TryGetServiceHost (string path, out WebSocketServiceHost host) { - host = null; + if (path == null) + throw new ArgumentNullException ("path"); - if (path == null || path.Length == 0) - return false; + if (path.Length == 0) + throw new ArgumentException ("An empty string.", "path"); if (path[0] != '/') - return false; + throw new ArgumentException ("Not an absolute path.", "path"); - if (path.IndexOfAny (new[] { '?', '#' }) > -1) - return false; + if (path.IndexOfAny (new[] { '?', '#' }) > -1) { + var msg = "It includes either or both query and fragment components."; + throw new ArgumentException (msg, "path"); + } return InternalTryGetServiceHost (path, out host); }