aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2011-07-18 14:21:45 +0200
committerLoïc Hoguin <[email protected]>2011-07-18 14:21:45 +0200
commitd363f914107d156f52ad73bf6bc3afcf0b1db701 (patch)
tree4fb39dfb764a24d28c615982ba0f37dc953ed72d /src/cowboy.erl
parent87366e36adc74caffbb3680fe1cfd07fc5b2cfef (diff)
downloadcowboy-d363f914107d156f52ad73bf6bc3afcf0b1db701.tar.gz
cowboy-d363f914107d156f52ad73bf6bc3afcf0b1db701.tar.bz2
cowboy-d363f914107d156f52ad73bf6bc3afcf0b1db701.zip
Fail fast when a wrong type is given to API functions
Idea given by bfrog, fixes issue #34.
Diffstat (limited to 'src/cowboy.erl')
-rw-r--r--src/cowboy.erl4
1 files changed, 3 insertions, 1 deletions
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 @@
%% <em>Ref</em> 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