Browse Source

Use try/catch instead of catch

Thanks Richard Carlsson for the remainder.
Loïc Hoguin 11 years ago
parent
commit
ff4871a9c9
1 changed files with 3 additions and 3 deletions
  1. 3 3
      src/cowboy_protocol.erl

+ 3 - 3
src/cowboy_protocol.erl

@@ -425,15 +425,15 @@ request(B, State=#state{transport=Transport}, M, P, Q, Version, Headers) ->
 			request(B, State, M, P, Q, Version, Headers,
 				<<>>, default_port(Transport:name()));
 		{_, RawHost} ->
-			case catch parse_host(RawHost, false, <<>>) of
-				{'EXIT', _} ->
-					error_terminate(400, State);
+			try parse_host(RawHost, false, <<>>) of
 				{Host, undefined} ->
 					request(B, State, M, P, Q, Version, Headers,
 						Host, default_port(Transport:name()));
 				{Host, Port} ->
 					request(B, State, M, P, Q, Version, Headers,
 						Host, Port)
+			catch _:_ ->
+				error_terminate(400, State)
 			end
 	end.