diff --git a/debugger/main.ml b/debugger/main.ml index 85bc9afb6..28c30e335 100644 --- a/debugger/main.ml +++ b/debugger/main.ml @@ -218,7 +218,7 @@ let main () = with Toplevel -> exit 2 - | Env.Error e -> + | Env.Error (e, _) -> eprintf "Debugger [version %s] environment error:@ @[@;" Config.version; Env.report_error err_formatter e; eprintf "@]@."; diff --git a/driver/errors.ml b/driver/errors.ml index 451c8303e..e97a874c1 100644 --- a/driver/errors.ml +++ b/driver/errors.ml @@ -21,9 +21,6 @@ open Format let report_error ppf exn = let report ppf = function - | Env.Error err -> - Location.print_error_cur_file ppf; - Env.report_error ppf err | Cmi_format.Error err -> Location.print_error_cur_file ppf; Cmi_format.report_error ppf err diff --git a/driver/opterrors.ml b/driver/opterrors.ml index 9793ffba2..32adc1b2c 100644 --- a/driver/opterrors.ml +++ b/driver/opterrors.ml @@ -20,9 +20,6 @@ open Format let report_error ppf exn = let report ppf = function - | Env.Error err -> - Location.print_error_cur_file ppf; - Env.report_error ppf err | Cmi_format.Error err -> Location.print_error_cur_file ppf; Cmi_format.report_error ppf err diff --git a/driver/pparse.ml b/driver/pparse.ml index ce5ae5764..7d039fa42 100644 --- a/driver/pparse.ml +++ b/driver/pparse.ml @@ -148,7 +148,8 @@ let () = Location.register_error_of_exn (function | Error (err, file) -> - Some (Location.error_of_printer (Location.in_file file) report_error err) + Some + (Location.error_of_printer (Location.in_file file) report_error err) | _ -> None ) diff --git a/ocamldoc/odoc_analyse.ml b/ocamldoc/odoc_analyse.ml index a1c5d1150..37a83b504 100644 --- a/ocamldoc/odoc_analyse.ml +++ b/ocamldoc/odoc_analyse.ml @@ -108,9 +108,6 @@ module Sig_analyser = Odoc_sig.Analyser (Odoc_comments.Basic_info_retriever) differences only concern code generation (i believe).*) let process_error exn = let report ppf = function - | Env.Error err -> - Location.print_error_cur_file ppf; - Env.report_error ppf err | Cmi_format.Error err -> Location.print_error_cur_file ppf; Cmi_format.report_error ppf err diff --git a/typing/env.ml b/typing/env.ml index 506975f7e..8a7fa232d 100644 --- a/typing/env.ml +++ b/typing/env.ml @@ -58,7 +58,9 @@ type error = | Inconsistent_import of string * string * string | Need_recursive_types of string * string -exception Error of error +exception Error of error * string + +let error err = raise (Error (err, !Location.input_name)) module EnvLazy : sig type ('a,'b) t @@ -289,7 +291,7 @@ let check_consistency filename crcs = (fun (name, crc) -> Consistbl.check crc_units name crc filename) crcs with Consistbl.Inconsistency(name, source, auth) -> - raise(Error(Inconsistent_import(name, auth, source))) + error (Inconsistent_import(name, auth, source)) (* Reading persistent structures from .cmi files *) @@ -310,12 +312,12 @@ let read_pers_struct modname filename = ( ps_filename = filename; ps_flags = flags } in if ps.ps_name <> modname then - raise(Error(Illegal_renaming(modname, ps.ps_name, filename))); + error (Illegal_renaming(modname, ps.ps_name, filename)); check_consistency filename ps.ps_crcs; List.iter (function Rectypes -> if not !Clflags.recursive_types then - raise(Error(Need_recursive_types(ps.ps_name, !current_unit)))) + error (Need_recursive_types(ps.ps_name, !current_unit))) ps.ps_flags; Hashtbl.add persistent_structures modname (Some ps); ps @@ -1603,3 +1605,14 @@ let report_error ppf = function fprintf ppf "@[Unit %s imports from %s, which uses recursive types.@ %s@]" export import "The compilation flag -rectypes is required" + +let () = + Location.register_error_of_exn + (function + | Error (err, file) -> + Some + (Location.error_of_printer (Location.in_file file) report_error err) + | _ -> + None + ) + diff --git a/typing/env.mli b/typing/env.mli index 38d8ceead..7a6ea4b2d 100644 --- a/typing/env.mli +++ b/typing/env.mli @@ -174,7 +174,7 @@ type error = | Inconsistent_import of string * string * string | Need_recursive_types of string * string -exception Error of error +exception Error of error * string (* file name *) open Format