@@ -52,7 +52,7 @@ def parse_any_tag
52
52
if @found_doctype
53
53
raise (
54
54
SyntaxTree ::Parser ::ParseError . new (
55
- "Only one doctype element is allowed " ,
55
+ "Duplicate doctype declaration " ,
56
56
tag . location . start_line ,
57
57
0
58
58
)
@@ -129,7 +129,7 @@ def make_tokens
129
129
else
130
130
raise (
131
131
SyntaxTree ::Parser ::ParseError . new (
132
- "Unexpected character at #{ index } : #{ source [ index ] } " ,
132
+ "Unexpected character: #{ source [ index ] } " ,
133
133
line ,
134
134
0
135
135
)
@@ -218,7 +218,7 @@ def make_tokens
218
218
else
219
219
raise (
220
220
SyntaxTree ::Parser ::ParseError . new (
221
- "Unexpected character in string at #{ index } : #{ source [ index ] } " ,
221
+ "Unexpected character, #{ source [ index ] } , when looking for closing single quote " ,
222
222
line ,
223
223
0
224
224
)
@@ -246,7 +246,7 @@ def make_tokens
246
246
else
247
247
raise (
248
248
SyntaxTree ::Parser ::ParseError . new (
249
- "Unexpected character in string at #{ index } : #{ source [ index ] } " ,
249
+ "Unexpected character, #{ source [ index ] } , when looking for closing double quote " ,
250
250
line ,
251
251
0
252
252
)
@@ -305,7 +305,7 @@ def make_tokens
305
305
else
306
306
raise (
307
307
SyntaxTree ::Parser ::ParseError . new (
308
- "Unexpected character at #{ index } : #{ source [ index ] } " ,
308
+ "Unexpected character, #{ source [ index ] } , when parsing HTML- or ERB-tag " ,
309
309
line ,
310
310
0
311
311
)
@@ -406,7 +406,7 @@ def parse_html_opening_tag
406
406
if name . value =~ /\A [@:#]/
407
407
raise (
408
408
SyntaxTree ::Parser ::ParseError . new (
409
- "Invalid html -tag name #{ name } " ,
409
+ "Invalid HTML -tag name #{ name . value } " ,
410
410
name . location . start_line ,
411
411
0
412
412
)
@@ -470,7 +470,7 @@ def parse_html_element
470
470
if closing . nil?
471
471
raise (
472
472
SyntaxTree ::Parser ::ParseError . new (
473
- "Missing closing tag for <#{ opening . name . value } > at #{ opening . location } " ,
473
+ "Missing closing tag for <#{ opening . name . value } >" ,
474
474
opening . location . start_line ,
475
475
0
476
476
)
@@ -480,7 +480,7 @@ def parse_html_element
480
480
if closing . name . value != opening . name . value
481
481
raise (
482
482
SyntaxTree ::Parser ::ParseError . new (
483
- "Expected closing tag for <#{ opening . name . value } > but got <#{ closing . name . value } > at #{ closing . location } " ,
483
+ "Expected closing tag for <#{ opening . name . value } > but got <#{ closing . name . value } >" ,
484
484
closing . location . start_line ,
485
485
0
486
486
)
@@ -505,10 +505,11 @@ def parse_erb_case(erb_node)
505
505
506
506
unless erb_tag . is_a? ( ErbCaseWhen ) || erb_tag . is_a? ( ErbElse ) ||
507
507
erb_tag . is_a? ( ErbEnd )
508
+ location = erb_tag &.location || erb_node . location
508
509
raise (
509
510
SyntaxTree ::Parser ::ParseError . new (
510
- "Found no matching erb -tag to the if-tag at #{ erb_node . location } " ,
511
- erb_node . location . start_line ,
511
+ "No matching ERB -tag for the <% #{ erb_node . keyword . value } %>-statement " ,
512
+ location . start_line ,
512
513
0
513
514
)
514
515
)
@@ -532,7 +533,7 @@ def parse_erb_case(erb_node)
532
533
else
533
534
raise (
534
535
SyntaxTree ::Parser ::ParseError . new (
535
- "Found no matching when- or else-tag to the case-tag at #{ erb_node . location } " ,
536
+ "No matching when- or else-tag for the case-tag" ,
536
537
erb_node . location . start_line ,
537
538
0
538
539
)
@@ -552,7 +553,7 @@ def parse_erb_if(erb_node)
552
553
unless erb_tag . is_a? ( ErbControl ) || erb_tag . is_a? ( ErbEnd )
553
554
raise (
554
555
SyntaxTree ::Parser ::ParseError . new (
555
- "Found no matching erb -tag to the if-tag at #{ erb_node . location } " ,
556
+ "Found no matching ERB -tag for the <% if %>-statement " ,
556
557
erb_node . location . start_line ,
557
558
0
558
559
)
@@ -584,7 +585,7 @@ def parse_erb_if(erb_node)
584
585
else
585
586
raise (
586
587
SyntaxTree ::Parser ::ParseError . new (
587
- "Found no matching elsif- or else-tag to the if-tag at #{ erb_node . location } " ,
588
+ "Found no matching elsif- or else-tag for the if-tag" ,
588
589
erb_node . location . start_line ,
589
590
0
590
591
)
@@ -600,7 +601,7 @@ def parse_erb_else(erb_node)
600
601
unless erb_end . is_a? ( ErbEnd )
601
602
raise (
602
603
SyntaxTree ::Parser ::ParseError . new (
603
- "Found no matching end-tag for the else-tag at #{ erb_node . location } " ,
604
+ "Found no matching end-tag for the else-tag" ,
604
605
erb_node . location . start_line ,
605
606
0
606
607
)
@@ -642,8 +643,8 @@ def parse_erb_tag
642
643
if !closing_tag . is_a? ( ErbClose )
643
644
raise (
644
645
SyntaxTree ::Parser ::ParseError . new (
645
- "Found no matching closing tag for the erb -tag at #{ opening_tag . location } " ,
646
- opening_tag . location . start_line ,
646
+ "Found no matching closing tag for the ERB -tag" ,
647
+ closing_tag . location . start_line ,
647
648
0
648
649
)
649
650
)
@@ -678,7 +679,7 @@ def parse_erb_tag
678
679
unless erb_end . is_a? ( ErbEnd )
679
680
raise (
680
681
SyntaxTree ::Parser ::ParseError . new (
681
- "Found no matching end-tag for the do-tag at #{ erb_node . location } " ,
682
+ "No matching <% end %> for the <% do %>-statement " ,
682
683
erb_node . location . start_line ,
683
684
0
684
685
)
@@ -695,27 +696,6 @@ def parse_erb_tag
695
696
erb_node
696
697
end
697
698
end
698
- rescue SyntaxTree ::Parser ::ParseError => error
699
- # If we have parsed tokens that we cannot process after we parsed <%, we should throw a ParseError
700
- # and not let it be handled by a `maybe`.
701
- if opening_tag
702
- message =
703
- if error . message . include? ( "Could not parse ERB-tag" )
704
- error . message
705
- else
706
- "Could not parse ERB-tag: #{ error . message } "
707
- end
708
-
709
- raise (
710
- SyntaxTree ::Parser ::ParseError . new (
711
- message ,
712
- opening_tag . location . start_line ,
713
- 0
714
- )
715
- )
716
- else
717
- raise ( error )
718
- end
719
699
end
720
700
721
701
def parse_until_erb_close
0 commit comments