]> matita.cs.unibo.it Git - helm.git/blobdiff - matita/matita/matitaExcPp.ml
Porting to ocaml 5
[helm.git] / matita / matita / matitaExcPp.ml
index 5ecea5dc85af80a7058da057170fc92f53f01c47..169800e5997fd6ee92e46e7f64bc77906090140c 100644 (file)
@@ -106,14 +106,15 @@ let compact_disambiguation_errors all_passes errorll =
       filter choices
    in
     filter_phase_3
-     (List.map (fun o,l -> o,List.sort choices_compare_by_passes l)
+     (List.map (fun (o,l) -> o,List.sort choices_compare_by_passes l)
        (uniq (List.stable_sort choices_compare choices)))
   in
    choices
 ;;
 
-let rec to_string = 
-  function
+let rec to_string exn =
+ try
+  (match exn with
     HExtlib.Localized (floc,exn) ->
       let _,msg = to_string exn in
       let (x, y) = HExtlib.loc_of_floc floc in
@@ -123,7 +124,7 @@ let rec to_string =
   | GrafiteTypes.Command_error msg -> None, "Error: " ^ msg
   | CicNotationParser.Parse_error err ->
       None, sprintf "Parse error: %s" err
-  | Unix.Unix_error (code, api, param) ->
+  | Unix.Unix_error (code, api, _param) ->
       let err = Unix.error_message code in
       None, "Unix Error (" ^ api ^ "): " ^ err
   | HMarshal.Corrupt_file fname -> None, sprintf "file '%s' is corrupt" fname
@@ -139,6 +140,8 @@ let rec to_string =
      None, "NRefiner uncertain: " ^ snd (Lazy.force msg)
   | NCicMetaSubst.Uncertain msg ->
      None, "NCicMetaSubst uncertain: " ^ Lazy.force msg
+  | NCicMetaSubst.MetaSubstFailure msg ->
+     None, "NCicMetaSubst failure: " ^ Lazy.force msg
   | NCicTypeChecker.TypeCheckerFailure msg ->
      None, "NTypeChecker failure: " ^ Lazy.force msg
   | NCicTypeChecker.AssertFailure msg ->
@@ -152,8 +155,7 @@ let rec to_string =
   | MatitaEngine.TryingToAdd msg ->
      None, "Attempt to insert an alias in batch mode: " ^ Lazy.force msg
   | MatitaEngine.AlreadyLoaded msg ->
-     None, "The file " ^ Lazy.force msg ^ " needs recompilation but it is
-     already loaded; undo the inclusion and try again."
+     None, "The file " ^ Lazy.force msg ^ " needs recompilation but it is already loaded; undo the inclusion and try again."
   | MatitaEngine.FailureCompiling (filename,exn) ->
      None, "Compiling " ^ filename ^ ":\n" ^ snd (to_string exn)
   | NCicRefiner.AssertFailure msg ->
@@ -169,6 +171,8 @@ let rec to_string =
      None, "NCicUnification uncertain: " ^ Lazy.force msg
   | DisambiguateChoices.Choice_not_found msg ->
      None, ("Disambiguation choice not found: " ^ Lazy.force msg)
+  | DisambiguateTypes.Invalid_choice msg ->
+     None, ("Invalid choice: " ^ snd (Lazy.force msg))
   | MatitaEngine.EnrichedWithStatus (exn,_) ->
      None, snd(to_string exn)
   | NTacStatus.Error (msg,None) ->
@@ -234,5 +238,7 @@ let rec to_string =
       loc,
        "********** DISAMBIGUATION ERRORS: **********\n" ^
         explain (aux errorll)
-  | exn -> None, "Uncaught exception: " ^ Printexc.to_string exn
-
+  | exn -> None, ("Uncaught exception: " ^ Printexc.to_string exn ^ Printexc.get_backtrace ()))
+ with exn ->
+  None, ("Exception raised during pretty-printing of an exception: " ^
+   snd (to_string exn))