| 1 |
= MLtonExn |
| 2 |
|
| 3 |
[source,sml] |
| 4 |
---- |
| 5 |
signature MLTON_EXN = |
| 6 |
sig |
| 7 |
val addExnMessager: (exn -> string option) -> unit |
| 8 |
val history: exn -> string list |
| 9 |
|
| 10 |
val defaultTopLevelHandler: exn -> 'a |
| 11 |
val getTopLevelHandler: unit -> (exn -> unit) |
| 12 |
val setTopLevelHandler: (exn -> unit) -> unit |
| 13 |
val topLevelHandler: exn -> 'a |
| 14 |
end |
| 15 |
---- |
| 16 |
|
| 17 |
* `addExnMessager f` |
| 18 |
+ |
| 19 |
adds `f` as a pretty-printer to be used by `General.exnMessage` for |
| 20 |
converting exceptions to strings. Messagers are tried in order from |
| 21 |
most recently added to least recently added. |
| 22 |
|
| 23 |
* `history e` |
| 24 |
+ |
| 25 |
returns call stack at the point that `e` was first raised. Each |
| 26 |
element of the list is a file position. The elements are in reverse |
| 27 |
chronological order, i.e. the function called last is at the front of |
| 28 |
the list. |
| 29 |
+ |
| 30 |
`history e` will return `[]` unless the program is compiled with |
| 31 |
`-const 'Exn.keepHistory true'`. |
| 32 |
|
| 33 |
* `defaultTopLevelHandler e` |
| 34 |
+ |
| 35 |
function that behaves as the default top level handler; that is, print |
| 36 |
out the unhandled exception message for `e` and exit. |
| 37 |
|
| 38 |
* `getTopLevelHandler ()` |
| 39 |
+ |
| 40 |
get the top level handler. |
| 41 |
|
| 42 |
* `setTopLevelHandler f` |
| 43 |
+ |
| 44 |
set the top level handler to the function `f`. The function `f` |
| 45 |
should not raise an exception or return normally. |
| 46 |
|
| 47 |
* `topLevelHandler e` |
| 48 |
+ |
| 49 |
behaves as if the top level handler received the exception `e`. |