aboutsummaryrefslogtreecommitdiffstats
path: root/src/ranch.erl
diff options
context:
space:
mode:
authorAlexey Lebedeff <[email protected]>2016-04-22 17:33:34 +0300
committerLoïc Hoguin <[email protected]>2016-11-15 15:46:54 +0200
commitf33ff7cbacb204adae9d53ad15829f44c4140525 (patch)
treeeb4b031b5e887e4fdc2391cecb3acb6511de735c /src/ranch.erl
parentdff4ea04dc0e286e8cb43fea0177d3efc249aec5 (diff)
downloadranch-f33ff7cbacb204adae9d53ad15829f44c4140525.tar.gz
ranch-f33ff7cbacb204adae9d53ad15829f44c4140525.tar.bz2
ranch-f33ff7cbacb204adae9d53ad15829f44c4140525.zip
Improve error reporting
Simplify some return values, improve error messages for eaddrinuse and no_cert. Amended to add tests and simpler code. Also hides the contents of cert and key transport options, if any.
Diffstat (limited to 'src/ranch.erl')
-rw-r--r--src/ranch.erl13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/ranch.erl b/src/ranch.erl
index 7f751cf..9eb9a47 100644
--- a/src/ranch.erl
+++ b/src/ranch.erl
@@ -74,9 +74,20 @@ start_listener(Ref, NumAcceptors, Transport, TransOpts, Protocol, ProtoOpts)
_ ->
ok
end,
- Res
+ maybe_started(Res)
end.
+maybe_started({error, {{shutdown,
+ {failed_to_start_child, ranch_acceptors_sup,
+ {listen_error, _, Reason}}}, _}} = Error) ->
+ start_error(Reason, Error);
+maybe_started(Res) ->
+ Res.
+
+start_error(E=eaddrinuse, _) -> {error, E};
+start_error(E=no_cert, _) -> {error, E};
+start_error(_, Error) -> Error.
+
-spec stop_listener(ref()) -> ok | {error, not_found}.
stop_listener(Ref) ->
case supervisor:terminate_child(ranch_sup, {ranch_listener_sup, Ref}) of