@@ -20,8 +20,7 @@ type pers_flags =
2020 | Unsafe_string
2121
2222type error =
23- Not_an_interface of string
24- | Wrong_version_interface of string * string
23+ Not_an_interface of string * string option
2524 | Corrupted_interface of string
2625
2726exception Error of error
@@ -56,11 +55,11 @@ let read_cmi filename =
5655 with
5756 | End_of_file | Failure _ | Parse_error (Corrupted _ ) ->
5857 fail (Corrupted_interface filename)
59- | Parse_error (Not_a_magic_number _ ) | Unexpected (Kind _ ) ->
60- fail (Not_an_interface filename)
61- | Unexpected (Version ( _cmi , { actual; expected } )) ->
62- let msg = if actual < expected then " an older " else " a newer " in
63- fail (Wrong_version_interface (filename, msg ))
58+ | Parse_error (Not_a_magic_number _ ) ->
59+ fail (Not_an_interface ( filename, None ) )
60+ | Unexpected error ->
61+ let explanation = explain error in
62+ fail (Not_an_interface (filename, Some explanation ))
6463 end )
6564 (fun () -> close_in ic)
6665
@@ -80,14 +79,20 @@ let output_cmi filename oc cmi =
8079open Format
8180
8281let report_error ppf = function
83- | Not_an_interface filename ->
84- fprintf ppf " %a@ is not a compiled interface"
85- Location. print_filename filename
82+ | Not_an_interface (filename , explanation ) ->
83+ fprintf ppf " %a@ is not a compiled interface."
84+ Location. print_filename filename;
85+ begin match explanation with
86+ | None -> ()
87+ | Some message -> fprintf ppf " \n %s" message
88+ end
89+ (*
8690 | Wrong_version_interface (filename, older_newer) ->
8791 fprintf ppf
8892 "%a@ is not a compiled interface for this version of OCaml.@.\
8993 It seems to be for %s version of OCaml."
9094 Location.print_filename filename older_newer
95+ *)
9196 | Corrupted_interface filename ->
9297 fprintf ppf " Corrupted compiled interface@ %a"
9398 Location. print_filename filename
0 commit comments