File: 09-Exceptions.md

package info (click to toggle)
storm-lang 0.7.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 52,028 kB
  • sloc: ansic: 261,471; cpp: 140,432; sh: 14,891; perl: 9,846; python: 2,525; lisp: 2,504; asm: 860; makefile: 678; pascal: 70; java: 52; xml: 37; awk: 12
file content (84 lines) | stat: -rw-r--r-- 2,055 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
Exceptions
==========

The standard library provides the type `core.Exception`, which is the root class for all exceptions
in Storm. Each exception contains a *message*, and optionally also a *stack trace*. It has the
following members:

```stormdoc
@core.Exception
- .message(*)
- .stackTrace
- .saveTrace()
```

The `saveTrace` function returns the exception itself. This makes it convenient to add a stack trace
to an exception temporarily by modifying code like:

```bsstmt
throw MyException();
```

into:

```bsstmt
throw MyException().saveTrace();
```


Exception Categories
--------------------

The following exceptions are provided in the standard library:

- [stormname:core.RuntimeError] extends `Exception`

  Depicts a runtime error from some part of the system. The following subclasses are provided:

  - [stormname:core.GcError] extends `RuntimeError`

    Thrown when the garbage collector detects an issue. Typically when available memory is low.

  - [stormname:core.NumericError] extends `RuntimeError`

    Thrown when a numeric operation failed.

    - [stormname:core.DivisionByZero] extends `NumericError`

      Thrown whenever division by zero is attempted.

  - [stormname:core.MemoryAccessError] extends `RuntimeError`

    Thrown when an invalid memory address was accessed.

  - [stormname:core.InternalError] extends `RuntimeError`

    Generic form of internal error.

  - [stormname:core.AbstractFnCalled] extends `RuntimeError`

    Thrown when an abstract function was called.

- [stormname:core.NotSupported] extends `Exception`

  Thrown when an operation is not supported.

- [stormname:core.UsageError] extends `Exception`

  Thrown when an interface is used incorrectly.

- [stormname:core.StrError] extends `Exception`

  Errors from `core.Str`.

- [stormname:core.MapError] extends `Exception`

  Errors from `core.Map` and `core.RefMap`.

- [stormname:core.SetError] extends `Exception`

  Errors from `core.Set` and `core.RefSet`.

- [stormname:core.ArrayError] extends `Exception`

  Errors from `core.Array`.