• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#  ``throw`` statements cannot accept values of arbitrary types
2
3Rule ``arkts-limited-throw``
4
5**Severity: error**
6
7ArkTS supports throwing only objects of the class ``Error`` or any
8derived class. Throwing an arbitrary type (i.e., a ``number`` or ``string``)
9is prohibited.
10
11
12## TypeScript
13
14
15```
16
17    throw 4
18    throw ""
19    throw new Error()
20
21```
22
23## ArkTS
24
25
26```
27
28    throw new Error()
29
30```
31
32
33