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