Skip to content

Commit 98b8046

Browse files
committed
Improve exceptions
1 parent fe39a63 commit 98b8046

10 files changed

+94
-84
lines changed

Diff for: Writerside/topics/language/basic-types.md

+9-14
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,6 @@ is **unacceptable**.
4646
> ```typescript
4747
> TrUe
4848
> ```
49-
> ```php
50-
> TypeLang\Parser\Node\Literal\BoolLiteralNode {
51-
> +offset: 0
52-
> +raw: "TrUe"
53-
> +value: true
54-
> }
55-
> ```
56-
> {collapsible="true" collapsed-title="TypeLang\Parser\Node\Literal\BoolLiteralNode"}
5749
>
5850
> {style="warning"}
5951
@@ -62,10 +54,11 @@ is **unacceptable**.
6254
> ```typescript
6355
> 42type
6456
> ```
57+
>
58+
> An error similar to the one below should occur
6559
> ```
66-
> Syntax error, unexpected "type"
60+
> ParseException: Syntax error, unexpected "type"
6761
> ```
68-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
6962
> {style="warning"}
7063
7164
</tab>
@@ -102,20 +95,22 @@ The namespace delimiter can be used in conjunction with keywords such as `true`,
10295
> ```typescript
10396
> true\null
10497
> ```
98+
>
99+
> An error similar to the one below should occur
105100
> ```
106-
> Syntax error, unexpected "\"
101+
> ParseException: Syntax error, unexpected "\"
107102
> ```
108-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
109103
> {style="warning"}
110104
111105
> <tooltip term="FQN">FQN</tooltip> type names cannot end in `\` delimiter.
112106
> ```typescript
113107
> example\name\
114108
> ```
109+
>
110+
> An error similar to the one below should occur
115111
> ```
116-
> Syntax error, unexpected end of input
112+
> ParseException: Syntax error, unexpected end of input
117113
> ```
118-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
119114
> {style="warning"}
120115
121116
</tab>

Diff for: Writerside/topics/language/callable-types.md

+18-12
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ Just like in the PHP language.
5050
> ```typescript
5151
> foo($name)
5252
> ```
53+
>
54+
> An error similar to the one below should occur
5355
> ```
54-
> Syntax error, unexpected ")"
56+
> ParseException: Syntax error, unexpected ")"
5557
> ```
56-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
5758
> {style="warning"}
5859
5960
</tab>
@@ -87,10 +88,11 @@ the type and before the name.
8788
> ```typescript
8889
> foo(&T)
8990
> ```
91+
>
92+
> An error similar to the one below should occur
9093
> ```
91-
> Syntax error, unexpected "&"
94+
> ParseException: Syntax error, unexpected "&"
9295
> ```
93-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
9496
> {style="warning"}
9597
9698
</tab>
@@ -134,10 +136,11 @@ parameter description.
134136
> ```typescript
135137
> foo(T= $name)
136138
> ```
139+
>
140+
> An error similar to the one below should occur
137141
> ```
138-
> Syntax error, unexpected "$name"
142+
> ParseException: Syntax error, unexpected "$name"
139143
> ```
140-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
141144
> {style="warning"}
142145
143146
</tab>
@@ -194,20 +197,22 @@ _before the type_ or _before the parameter name._
194197
> ```typescript
195198
> foo(...T...)
196199
> ```
200+
>
201+
> An error similar to the one below should occur
197202
> ```
198-
> Syntax error, unexpected "..."
203+
> ParseException: Syntax error, unexpected "..."
199204
> ```
200-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
201205
> {style="warning"}
202206
203207
> Variadic parameter cannot be optional.
204208
> ```typescript
205209
> foo(T ...$name=)
206210
> ```
211+
>
212+
> An error similar to the one below should occur
207213
> ```
208-
> Cannot have variadic param with a default
214+
> ParseException: Cannot have variadic param with a default
209215
> ```
210-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
211216
> {style="warning"}
212217
213218
</tab>
@@ -250,10 +255,11 @@ An attribute is additional metadata for a parameter.
250255
> ```typescript
251256
> Example\Functor(#[42] int $a): void
252257
> ```
258+
>
259+
> An error similar to the one below should occur
253260
> ```
254-
> Syntax error, unexpected "42"
261+
> ParseException: Syntax error, unexpected "42"
255262
> ```
256-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
257263
> {style="warning"}
258264
259265
</tab>

Diff for: Writerside/topics/language/const-types.md

+9-14
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,6 @@ Given the complete identity of the grammar of constants with
4242
> ```typescript
4343
> TrUe
4444
> ```
45-
> ```php
46-
> TypeLang\Parser\Node\Literal\BoolLiteralNode {
47-
> +offset: 0
48-
> +raw: "TrUe"
49-
> +value: true
50-
> }
51-
> ```
52-
> {collapsible="true" collapsed-title="TypeLang\Parser\Node\Literal\BoolLiteralNode"}
5345
> {style="warning"}
5446
5547
</tab>
@@ -81,10 +73,11 @@ a double colon (`::`) character, and then the constant name.
8173
> ```typescript
8274
> ClassName::SOME\ANY
8375
> ```
76+
>
77+
> An error similar to the one below should occur
8478
> ```
85-
> Syntax error, unexpected "\"
79+
> ParseException: Syntax error, unexpected "\"
8680
> ```
87-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
8881
> {style="warning"}
8982
9083
</tab>
@@ -124,20 +117,22 @@ Prefixes on class constants can be omitted, so type will mean any class constant
124117
> ```typescript
125118
> *
126119
> ```
120+
>
121+
> An error similar to the one below should occur
127122
> ```
128-
> Syntax error, unexpected "*"
123+
> ParseException: Syntax error, unexpected "*"
129124
> ```
130-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
131125
> {style="warning"}
132126
133127
> The asterisk (`*`) must be the final character.
134128
> ```typescript
135129
> Path\To\ClassName::PREFIX_*_SUFFIX
136130
> ```
131+
>
132+
> An error similar to the one below should occur
137133
> ```
138-
> Syntax error, unexpected "_SUFFIX"
134+
> ParseException: Syntax error, unexpected "_SUFFIX"
139135
> ```
140-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
141136
> {style="warning"}
142137
143138
</tab>

Diff for: Writerside/topics/language/generic-types.md

+19-13
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,22 @@ and the reference to the type:
5353
> ```typescript
5454
> example<>
5555
> ```
56+
>
57+
> An error similar to the one below should occur
5658
> ```
57-
> Syntax error, unexpected ">"
59+
> ParseException: Syntax error, unexpected ">"
5860
> ```
59-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
6061
> {style="warning"}
6162
6263
> Leading comma is NOT allowed.
6364
> ```typescript
6465
> example<,T>
6566
> ```
67+
>
68+
> An error similar to the one below should occur
6669
> ```
67-
> Syntax error, unexpected ","
70+
> ParseException: Syntax error, unexpected ","
6871
> ```
69-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
7072
> {style="warning"}
7173
7274
</tab>
@@ -98,20 +100,22 @@ used, for example, in static analyzers to indicate the
98100
> ```typescript
99101
> Collection<42 User>
100102
> ```
101-
> ```php
102-
> Syntax error, unexpected "User"
103+
>
104+
> An error similar to the one below should occur
105+
> ```
106+
> ParseException: Syntax error, unexpected "User"
103107
> ```
104-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
105108
> {style="warning"}
106109
107110
> Multiple hints are not allowed.
108111
> ```typescript
109112
> HashMap<array-key, some covariant Request>
110113
> ```
114+
>
115+
> An error similar to the one below should occur
111116
> ```
112-
> Syntax error, unexpected "Request"
117+
> ParseException: Syntax error, unexpected "Request"
113118
> ```
114-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
115119
> {style="warning"}
116120
117121
</tab>
@@ -143,10 +147,11 @@ In addition to modern list declarations such as `list<int>` or
143147
> ```typescript
144148
> User[int]
145149
> ```
150+
>
151+
> An error similar to the one below should occur
146152
> ```
147-
> Syntax error, unexpected "int"
153+
> ParseException: Syntax error, unexpected "int"
148154
> ```
149-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
150155
> {style="warning"}
151156
152157
</tab>
@@ -185,10 +190,11 @@ An attribute is additional metadata for an argument.
185190
> ```typescript
186191
> Collection<#[42] User>
187192
> ```
193+
>
194+
> An error similar to the one below should occur
188195
> ```
189-
> Syntax error, unexpected "42"
196+
> ParseException: Syntax error, unexpected "42"
190197
> ```
191-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
192198
> {style="warning"}
193199
194200
</tab>

Diff for: Writerside/topics/language/literal-types.md

+15-10
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,11 @@ numbers `1` and `0` and must match the regular expression `0b[0-1]+`.
169169
> ```typescript
170170
> 0b101042
171171
> ```
172+
>
173+
> An error similar to the one below should occur
172174
> ```
173-
> Syntax error, unexpected "42"
175+
> ParseException: Syntax error, unexpected "42"
174176
> ```
175-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
176177
> {style="warning"}
177178
178179
</tab>
@@ -218,10 +219,11 @@ numbers between `0` and `7` and must match the regular expression
218219
> ```typescript
219220
> 0o4281
220221
> ```
222+
>
223+
> An error similar to the one below should occur
221224
> ```
222-
> Syntax error, unexpected "81"
225+
> ParseException: Syntax error, unexpected "81"
223226
> ```
224-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
225227
> {style="warning"}
226228
227229
</tab>
@@ -303,20 +305,22 @@ trailing number may be omitted. Negative values are prefixed with a minus (`-`.
303305
> ```typescript
304306
> .
305307
> ```
308+
>
309+
> An error similar to the one below should occur
306310
> ```
307-
> Syntax error, unexpected "."
311+
> ParseException: Syntax error, unexpected "."
308312
> ```
309-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
310313
> {style="warning"}
311314
312315
> Only number between `0` and `9` are allowed.
313316
> ```typescript
314317
> 0.0A
315318
> ```
319+
>
320+
> An error similar to the one below should occur
316321
> ```
317-
> Syntax error, unexpected "A"
322+
> ParseException: Syntax error, unexpected "A"
318323
> ```
319-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
320324
> {style="warning"}
321325
322326
</tab>
@@ -355,10 +359,11 @@ writing out an inconveniently long string of digits.
355359
> ```typescript
356360
> 10e-F
357361
> ```
362+
>
363+
> An error similar to the one below should occur
358364
> ```
359-
> Syntax error, unexpected "e-F"
365+
> ParseException: Syntax error, unexpected "e-F"
360366
> ```
361-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
362367
> {style="warning"}
363368
364369
</tab>

Diff for: Writerside/topics/language/logical-types.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ and is written as `?T.`
6868
> ```typescript
6969
> Example?
7070
> ```
71+
>
72+
> An error similar to the one below should occur
7173
> ```
72-
> Syntax error, unexpected "?"
74+
> ParseException: Syntax error, unexpected "?"
7375
> ```
74-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
7576
> {style="warning"}
7677
</tab>
7778
</tabs>

Diff for: Writerside/topics/language/offset-access.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,23 @@ The type of specific element, enclosed in square `[]` brackets.
4040
> ```typescript
4141
> Collection[[Some]]
4242
> ```
43+
>
44+
> An error similar to the one below should occur
4345
> ```
44-
> Syntax error, unexpected "["
46+
> ParseException: Syntax error, unexpected "["
4547
> ```
46-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
4748
> {style="warning"}
4849
4950
> There must be a type description first, followed
5051
> by a reference to an element of that type.
5152
> ```typescript
5253
> Collection['key']{key: string}
5354
> ```
55+
>
56+
> An error similar to the one below should occur
5457
> ```
55-
> Syntax error, unexpected "{"
58+
> ParseException: Syntax error, unexpected "{"
5659
> ```
57-
> {collapsible="true" collapsed-title="TypeLang\Parser\Exception\ParseException"}
5860
> {style="warning"}
5961
6062
</tab>

0 commit comments

Comments
 (0)