Exception

GitHub   Edit on GitHub

Utilities for working with the Exception type.

The Exception type represents an error that has occurred during computation.

Added in 0.3.0 No other changes yet.
1
from "exception" include Exception
1
exception ExampleError(Number)
1
exception ExampleError

Values

Functions and constants included in the Exception module.

Exception.registerPrinter

Added in 0.3.0 No other changes yet.
1
registerPrinter : (printer: (Exception => Option<String>)) => Void

Registers an exception printer. When an exception is thrown, all registered printers are called in order from the most recently registered printer to the least recently registered printer. The first Some value returned is used as the exception’s string value.

Parameters:

param type description
printer Exception => Option<String> The exception printer to register

Examples:

1
2
3
4
5
6
7
8
9
10
11
exception ExampleError(Number)

Exception.registerPrinter(e => {
match (e) {
ExampleError(lineNumber) =>
Some("Error found on line: " ++ toString(lineNumber)),
_ => None,
}
})

throw ExampleError(1) // Error found on line: 1
This is a notification!