[Modify] Throw exceptions
This commit is contained in:
parent
a26e0f9633
commit
9dcfc85c1c
@ -1052,15 +1052,21 @@ namespace WebSocketSharp.Server
|
|||||||
)
|
)
|
||||||
where TBehavior : WebSocketBehavior
|
where TBehavior : WebSocketBehavior
|
||||||
{
|
{
|
||||||
string msg;
|
if (path == null)
|
||||||
if (!checkServicePath (path, out msg)) {
|
throw new ArgumentNullException ("path");
|
||||||
_log.Error (msg);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (initializer == null) {
|
if (initializer == null)
|
||||||
_log.Error ("'initializer' is null.");
|
throw new ArgumentNullException ("initializer");
|
||||||
return;
|
|
||||||
|
if (path.Length == 0)
|
||||||
|
throw new ArgumentException ("An empty string.", "path");
|
||||||
|
|
||||||
|
if (path[0] != '/')
|
||||||
|
throw new ArgumentException ("Not an absolute path.", "path");
|
||||||
|
|
||||||
|
if (path.IndexOfAny (new[] { '?', '#' }) > -1) {
|
||||||
|
var msg = "It includes either or both query and fragment components.";
|
||||||
|
throw new ArgumentException (msg, "path");
|
||||||
}
|
}
|
||||||
|
|
||||||
_services.Add<TBehavior> (path, initializer);
|
_services.Add<TBehavior> (path, initializer);
|
||||||
|
Loading…
Reference in New Issue
Block a user