summaryrefslogtreecommitdiff
path: root/exn_handler.sml
diff options
context:
space:
mode:
authorVladimir Azarov <avm@intermediate-node.net>2025-04-04 20:53:56 +0200
committerVladimir Azarov <avm@intermediate-node.net>2025-04-04 20:53:56 +0200
commit9d724f17e813fa344d485329d33b5f5ecf8197a3 (patch)
tree5061e604ea88a379db975b13c1d20688007cacc8 /exn_handler.sml
parent7b29b31648fd737e7bbc007f480b799add91bc6b (diff)
Functorization
Diffstat (limited to 'exn_handler.sml')
-rw-r--r--exn_handler.sml46
1 files changed, 0 insertions, 46 deletions
diff --git a/exn_handler.sml b/exn_handler.sml
deleted file mode 100644
index 50fb8dc..0000000
--- a/exn_handler.sml
+++ /dev/null
@@ -1,46 +0,0 @@
-structure GlobalExnHandler: sig val handler: exn -> unit end = struct
-
- fun eprint s = printLn $ "error: " ^ s
-
- fun otherExn e =
- let
- val hist = MLton.Exn.history e
- in
- eprint $ "exception " ^ exnMessage e ^ " was raised";
- if hist = [] then
- (printLn "No stack trace is avaliable";
- printLn "Recompile with -const \"Exn.keepHistory true\"")
- else
- List.app (fn x => printLn $ "\t" ^ x) hist
- end
-
- fun exit code = Posix.Process.exit $ Word8.fromInt code
-
- fun ioExn (IO.Io { name, function = _, cause }) =
- let
- val prefix = name ^ ": "
- val reason =
- case cause of
- OS.SysErr (str, _) => str
- | _ => exnMessage cause
- in
- printLn $ prefix ^ reason
- end
- | ioExn _ = (printLn "ioExn: unreachable"; exit 254)
-
- fun handler e =
- let
- open Tokenizer Cpp
- in
- (case e of
- FsmTableIsTooSmall =>
- eprint "fsm table is too small. Increate 'maxState' value"
- | IO.Io _ => ioExn e
- | TkErrorAug (pos, msg) => eprint $ Stream.ppos2str pos ^ ": " ^ msg
- | TkExpected v => tkExpectedPrint v
- | _ => otherExn e;
- exit 255)
- end
-end
-
-val () = MLton.Exn.setTopLevelHandler GlobalExnHandler.handler