### ppatteries.ml [ocaml] module Sparse = struct exception Parse_error of string * (int * int) * (int * int) let () = Printexc.register_printer (function | Parse_error (msg, (l1, c1), (l2, c2)) -> Some (Printf.sprintf "%s between %d:%d and %d:%d" msg l1 c1 l2 c2) | _ -> None) (* ... *) end ### output.txt Fatal error: exception Ppatteries.Sparse.Parse_error("syntax error lexing", _, _) Raised at file "parsing.ml", line 179, characters 14-17 Called from file "str.ml", line 0, characters 0-0 Called from file "src/batList.ml", line 103, characters 17-20 Called from file "src/batStd.ml", line 226, characters 17-20