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 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/errors.mli | 27 +++++++++++++++++++++++++++ lib/lib.mllib | 3 ++- 3 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 lib/errors.ml create mode 100644 lib/errors.mli (limited to 'lib') 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 + diff --git a/lib/errors.mli b/lib/errors.mli new file mode 100644 index 0000000000..120634e60d --- /dev/null +++ b/lib/errors.mli @@ -0,0 +1,27 @@ +(***********************************************************************) +(* v * The Coq Proof Assistant / The Coq Development Team *) +(* Pp.std_ppcmds) -> unit + +val print : exn -> Pp.std_ppcmds diff --git a/lib/lib.mllib b/lib/lib.mllib index cfbedcc52d..84180fc46b 100644 --- a/lib/lib.mllib +++ b/lib/lib.mllib @@ -5,6 +5,7 @@ Flags Segmenttree Unicodetable Util +Errors Bigint Hashcons Dyn @@ -23,4 +24,4 @@ Heap Option Dnet Store -Unionfind \ No newline at end of file +Unionfind -- cgit v1.2.3