Browse Source

Clarify error msg for route lacking starting slash

Danielle Sucher 11 years ago
parent
commit
37e98f019d
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/cowboy_router.erl

+ 4 - 1
src/cowboy_router.erl

@@ -92,7 +92,10 @@ compile_paths([{<< $/, PathMatch/binary >>, Constraints, Handler, Opts}|Tail],
 		Acc) ->
 	PathRules = compile_rules(PathMatch, $/, [], [], <<>>),
 	Paths = [{lists:reverse(R), Constraints, Handler, Opts} || R <- PathRules],
-	compile_paths(Tail, Paths ++ Acc).
+	compile_paths(Tail, Paths ++ Acc);
+compile_paths([{PathMatch, _, _, _}|_], _) ->
+	error({badarg, "The following route MUST begin with a slash: "
+		++ binary_to_list(PathMatch)}).
 
 compile_rules(<<>>, _, Segments, Rules, <<>>) ->
 	[Segments|Rules];