]> matita.cs.unibo.it Git - helm.git/blob - helm/matita/matitaExcPp.ml
ocaml 3.09 transition
[helm.git] / helm / matita / matitaExcPp.ml
1 (* Copyright (C) 2004-2005, HELM Team.
2  * 
3  * This file is part of HELM, an Hypertextual, Electronic
4  * Library of Mathematics, developed at the Computer Science
5  * Department, University of Bologna, Italy.
6  * 
7  * HELM is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  * 
12  * HELM is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with HELM; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://helm.cs.unibo.it/
24  *)
25
26 open Printf
27
28 let to_string = 
29   function
30   | MatitaTypes.Option_error ("baseuri", "not found" ) -> 
31       "Baseuri not set for this script. "
32       ^ "Use 'set \"baseuri\" \"<uri>\".' to set it."
33   | MatitaTypes.Command_error msg -> "Error: " ^ msg
34   | CicNotationParser.Parse_error (floc,err) ->
35       let (x, y) = CicNotationPt.loc_of_floc floc in
36       sprintf "Parse error at %d-%d: %s" x y err
37   | UriManager.IllFormedUri uri -> sprintf "invalid uri: %s" uri
38   | CicEnvironment.Object_not_found uri ->
39       sprintf "object not found: %s" (UriManager.string_of_uri uri)
40   | Unix.Unix_error (code, api, param) ->
41       let err = Unix.error_message code in
42       "Unix Error (" ^ api ^ "): " ^ err
43   | MatitaMoo.Corrupt_moo fname ->
44       sprintf ".moo file '%s' is corrupt (shorter than expected)" fname
45   | MatitaMoo.Checksum_failure fname ->
46       sprintf "checksum failed for .moo file '%s', please recompile it'" fname
47   | MatitaMoo.Version_mismatch fname ->
48       sprintf
49         (".moo file '%s' has been compiled by a different version of matita, "
50         ^^ "please recompile it")
51         fname
52   | ProofEngineTypes.Fail msg -> "Tactic error: " ^ Lazy.force msg
53   | Continuationals.Error s -> "Tactical error: " ^ Lazy.force s
54   | CicTypeChecker.TypeCheckerFailure msg ->
55      "Type checking error: " ^ Lazy.force msg
56   | CicTypeChecker.AssertFailure msg ->
57      "Type checking assertion failed: " ^ Lazy.force msg
58   | MatitaDisambiguator.DisambiguationError errorll ->
59      let rec aux n =
60       function
61          [] -> ""
62        | phase::tl ->
63           aux (n+1) tl ^
64            "***** Errors obtained during phase " ^ string_of_int n ^": *****\n"^
65             String.concat "\n\n"
66              (List.map (fun msg -> "*Error: " ^ Lazy.force msg) phase) ^
67             "\n\n\n"
68      in
69       "********** DISAMBIGUATION ERRORS: **********\n" ^
70        aux 1 errorll
71   | exn -> "Uncaught exception: " ^ Printexc.to_string exn
72