Permalink
Browse files

make joxa throw a useful error on invalid patterns

  • Loading branch information...
1 parent fc09828 commit 85d82d9ff84d612d10f930294cde76e98ba16b2a @ericbmerritt ericbmerritt committed Jan 15, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 src/jxa_clause.erl
View
8 src/jxa_clause.erl
@@ -124,8 +124,12 @@ comp_pattern(Path0, Acc0, [list | Args]) ->
mk_list(Path1, Acc0, Args);
comp_pattern(Path0, Acc0, [tuple | Args]) ->
mk_tuple(Path0, Acc0, Args);
-comp_pattern(Path0, Ctx0, Arg) when is_tuple(Arg) ->
- mk_tuple(Path0, Ctx0, tuple_to_list(Arg)).
+comp_pattern(Path0, Acc0, Arg) when is_tuple(Arg) ->
+ mk_tuple(Path0, Acc0, tuple_to_list(Arg));
+comp_pattern(Path0, {Ctx0, _}, _Arg) ->
+ Idx = jxa_annot:get_idx(jxa_path:path(Path0),
+ jxa_ctx:annots(Ctx0)),
+ ?JXA_THROW({invalid_pattern, Idx}).
mk_guards(GuardAnnots, []) ->
cerl:ann_c_atom(GuardAnnots, true);

0 comments on commit 85d82d9

Please sign in to comment.