Skip to content

Commit b8e6716

Browse files
committed
Rename Template_parse_error into Parse_error
The idea was to leave space for "JSON parse error", but those can be just JSON_error.
1 parent f760380 commit b8e6716

File tree

4 files changed

+25
-25
lines changed

4 files changed

+25
-25
lines changed

bin/mustache_cli.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ let load_template template_filename =
2828
lexbuf.lex_curr_p <- { lexbuf.lex_curr_p with pos_fname = template_filename };
2929
in
3030
try Mustache.parse_lx lexbuf
31-
with Mustache.Template_parse_error err ->
32-
Format.eprintf "Template parse error:@\n%a@."
31+
with Mustache.Parse_error err ->
32+
Format.eprintf "Parse error:@\n%a@."
3333
Mustache.pp_template_parse_error err;
3434
exit 3
3535

bin/test/errors/parsing-errors.t

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,71 +4,71 @@ Delimiter problems:
44
$ PROBLEM=no-closing-mustache.mustache
55
$ echo "{{foo" > $PROBLEM
66
$ mustache foo.json $PROBLEM
7-
Template parse error:
7+
Parse error:
88
File "no-closing-mustache.mustache", line 2, character 0: '}}' expected.
99
[3]
1010
1111
$ PROBLEM=one-closing-mustache.mustache
1212
$ echo "{{foo}" > $PROBLEM
1313
$ mustache foo.json $PROBLEM
14-
Template parse error:
14+
Parse error:
1515
File "one-closing-mustache.mustache", line 1, character 5: '}}' expected.
1616
[3]
1717
1818
$ PROBLEM=eof-before-variable.mustache
1919
$ echo "{{" > $PROBLEM
2020
$ mustache foo.json $PROBLEM
21-
Template parse error:
21+
Parse error:
2222
File "eof-before-variable.mustache", line 2, character 0: ident expected.
2323
[3]
2424
2525
$ PROBLEM=eof-before-section.mustache
2626
$ echo "{{#" > $PROBLEM
2727
$ mustache foo.json $PROBLEM
28-
Template parse error:
28+
Parse error:
2929
File "eof-before-section.mustache", line 2, character 0: ident expected.
3030
[3]
3131
3232
$ PROBLEM=eof-before-section-end.mustache
3333
$ echo "{{#foo}} {{.}} {{/" > $PROBLEM
3434
$ mustache foo.json $PROBLEM
35-
Template parse error:
35+
Parse error:
3636
File "eof-before-section-end.mustache", line 2, character 0: ident expected.
3737
[3]
3838
3939
$ PROBLEM=eof-before-inverted-section.mustache
4040
$ echo "{{^" > $PROBLEM
4141
$ mustache foo.json $PROBLEM
42-
Template parse error:
42+
Parse error:
4343
File "eof-before-inverted-section.mustache", line 2, character 0:
4444
ident expected.
4545
[3]
4646
4747
$ PROBLEM=eof-before-unescape.mustache
4848
$ echo "{{{" > $PROBLEM
4949
$ mustache foo.json $PROBLEM
50-
Template parse error:
50+
Parse error:
5151
File "eof-before-unescape.mustache", line 2, character 0: ident expected.
5252
[3]
5353
5454
$ PROBLEM=eof-before-unescape.mustache
5555
$ echo "{{&" > $PROBLEM
5656
$ mustache foo.json $PROBLEM
57-
Template parse error:
57+
Parse error:
5858
File "eof-before-unescape.mustache", line 2, character 0: ident expected.
5959
[3]
6060
6161
$ PROBLEM=eof-before-partial.mustache
6262
$ echo "{{>" > $PROBLEM
6363
$ mustache foo.json $PROBLEM
64-
Template parse error:
64+
Parse error:
6565
File "eof-before-partial.mustache", line 2, character 0: '}}' expected.
6666
[3]
6767
6868
$ PROBLEM=eof-in-comment.mustache
6969
$ echo "{{! non-terminated comment" > $PROBLEM
7070
$ mustache foo.json $PROBLEM
71-
Template parse error:
71+
Parse error:
7272
File "eof-in-comment.mustache", line 2, character 0: non-terminated comment.
7373
[3]
7474
@@ -78,14 +78,14 @@ Mismatches between opening and closing mustaches:
7878
$ PROBLEM=two-three.mustache
7979
$ echo "{{ foo }}}" > $PROBLEM
8080
$ mustache foo.json $PROBLEM
81-
Template parse error:
81+
Parse error:
8282
File "two-three.mustache", line 1, characters 7-10: '}}' expected.
8383
[3]
8484
8585
$ PROBLEM=three-two.mustache
8686
$ echo "{{{ foo }}" > $PROBLEM
8787
$ mustache foo.json $PROBLEM
88-
Template parse error:
88+
Parse error:
8989
File "three-two.mustache", line 1, characters 8-10: '}}}' expected.
9090
[3]
9191
@@ -95,22 +95,22 @@ Mismatch between section-start and section-end:
9595
$ PROBLEM=foo-bar.mustache
9696
$ echo "{{#foo}} {{.}} {{/bar}}" > $PROBLEM
9797
$ mustache foo.json $PROBLEM
98-
Template parse error:
98+
Parse error:
9999
File "foo-bar.mustache", line 1, characters 0-23:
100100
Section mismatch: {{#foo}} is closed by {{/bar}}.
101101
[3]
102102
103103
$ PROBLEM=foo-not-closed.mustache
104104
$ echo "{{#foo}} {{.}} {{foo}}" > $PROBLEM
105105
$ mustache foo.json $PROBLEM
106-
Template parse error:
106+
Parse error:
107107
File "foo-not-closed.mustache", line 2, character 0: syntax error.
108108
[3]
109109
110110
$ PROBLEM=wrong-nesting.mustache
111111
$ echo "{{#bar}} {{#foo}} {{.}} {{/bar}} {{/foo}}" > $PROBLEM
112112
$ mustache foo.json $PROBLEM
113-
Template parse error:
113+
Parse error:
114114
File "wrong-nesting.mustache", line 1, characters 9-32:
115115
Section mismatch: {{#foo}} is closed by {{/bar}}.
116116
[3]
@@ -121,6 +121,6 @@ Weird cases that may confuse our lexer or parser:
121121
$ PROBLEM=weird-tag-name.mustache
122122
$ echo "{{.weird}} foo bar" > $PROBLEM
123123
$ mustache foo.json $PROBLEM
124-
Template parse error:
124+
Parse error:
125125
File "weird-tag-name.mustache", line 1, character 3: '}}' expected.
126126
[3]

lib/mustache.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,14 @@ and template_parse_error_kind =
154154
end_name: dotted_name;
155155
}
156156

157-
exception Template_parse_error of template_parse_error
157+
exception Parse_error of template_parse_error
158158

159159
let parse_lx (lexbuf: Lexing.lexbuf) : Locs.t =
160160
let loc_of lexbuf =
161161
let open Lexing in
162162
{ loc_start = lexbuf.lex_start_p; loc_end = lexbuf.lex_curr_p } in
163163
let raise_err loc kind =
164-
raise (Template_parse_error { loc; kind })
164+
raise (Parse_error { loc; kind })
165165
in
166166
try
167167
MenhirLib.Convert.Simplified.traditional2revised
@@ -265,8 +265,8 @@ let () =
265265
pp_error err;
266266
Buffer.contents buf in
267267
Printexc.register_printer (function
268-
| Template_parse_error err ->
269-
Some (pretty_print "Template_parse_error" pp_template_parse_error err)
268+
| Parse_error err ->
269+
Some (pretty_print "Parse_error" pp_template_parse_error err)
270270
| Render_error err ->
271271
Some (pretty_print "Render_error" pp_render_error err)
272272
| _ -> None

lib/mustache.mli

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ type loc =
4040
{ loc_start: Lexing.position;
4141
loc_end: Lexing.position }
4242

43-
(** Read template files; those function may raise [Template_parse_error]. *)
43+
(** Read template files; those function may raise [Parse_error]. *)
4444
type template_parse_error
45-
exception Template_parse_error of template_parse_error
45+
exception Parse_error of template_parse_error
4646

4747
val parse_lx : Lexing.lexbuf -> t
4848
val of_string : string -> t
@@ -54,7 +54,7 @@ val of_string : string -> t
5454
5555
{|
5656
try ignore (Mustache.of_string "{{!")
57-
with Mustache.Template_parse_error err ->
57+
with Mustache.Parse_error err ->
5858
Format.eprintf "%a@." Mustache.pp_template_parse_error err
5959
|}
6060
*)

0 commit comments

Comments
 (0)