From d363f914107d156f52ad73bf6bc3afcf0b1db701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 18 Jul 2011 14:21:45 +0200 Subject: Fail fast when a wrong type is given to API functions Idea given by bfrog, fixes issue #34. --- src/cowboy.erl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/cowboy.erl') diff --git a/src/cowboy.erl b/src/cowboy.erl index dbc64d0..4a82cc1 100644 --- a/src/cowboy.erl +++ b/src/cowboy.erl @@ -38,7 +38,9 @@ %% Ref can be used to stop the listener later on. -spec start_listener(any(), non_neg_integer(), module(), any(), module(), any()) -> {ok, pid()}. -start_listener(Ref, NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts) -> +start_listener(Ref, NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts) + when is_integer(NbAcceptors) andalso is_atom(Transport) + andalso is_atom(Protocol) -> supervisor:start_child(cowboy_sup, {{cowboy_listener_sup, Ref}, {cowboy_listener_sup, start_link, [ NbAcceptors, Transport, TransOpts, Protocol, ProtoOpts -- cgit v1.2.3