Standard Library / Exception
Exception
Utilities for working with the Exception type.
Edit on GitHubThe Exception type represents an error that has occurred during computation.
Added in 0.3.0
No other changes yet.
from "exception" include Exception
exception ExampleError(Number)
exception ExampleError
Functions and constants included in the Exception module.
Added in 0.3.0
No other changes yet.
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 |
printer: The exception printer to registerExamples:
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