From edcf0d8b8bff399443ddf4cd436185c33bf59829 Mon Sep 17 00:00:00 2001 From: aspiwack Date: Fri, 13 May 2011 17:57:41 +0000 Subject: A new mechanism to handle errors. Instead of the monolitic Cerrors, I introduce a lightweight Errors module whose error message can be expanded by module introducing exceptions. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@14119 85f007b7-540e-0410-9357-904b9bb8a0f7 --- lib/errors.ml | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 lib/errors.ml (limited to 'lib/errors.ml') diff --git a/lib/errors.ml b/lib/errors.ml new file mode 100644 index 0000000000..89e924948e --- /dev/null +++ b/lib/errors.ml @@ -0,0 +1,56 @@ +(***********************************************************************) +(* v * The Coq Proof Assistant / The Coq Development Team *) +(* print_unhandled_exception e + | h::s' -> + try h e + with + | Unhandled -> print_gen s' e + | e' -> print_gen s' e' + +let print e = print_gen !handle_stack e + + +(*** Predefined handlers ***) + +let where s = + if !Flags.debug then (str"in " ++ str s ++ str":" ++ spc ()) else (mt ()) + +let _ = register_handler begin function + | Util.UserError(s,pps) -> + hov 0 (str "Error: " ++ where s ++ pps) + | Util.Anomaly (s,pps) -> + hov 0 (anomaly_string () ++ where s ++ pps ++ report_fn ()) + | _ -> raise Unhandled +end + -- cgit v1.2.3