Keep input file in Env.Error. Switch it to the new system.

git-svn-id: http://caml.inria.fr/svn/ocaml/branches/exception_registration@14109 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Alain Frisch 2013-09-12 13:00:22 +00:00
parent d18a044380
commit 290fe0c0b2
7 changed files with 21 additions and 16 deletions

View File

@ -218,7 +218,7 @@ let main () =
with with
Toplevel -> Toplevel ->
exit 2 exit 2
| Env.Error e -> | Env.Error (e, _) ->
eprintf "Debugger [version %s] environment error:@ @[@;" Config.version; eprintf "Debugger [version %s] environment error:@ @[@;" Config.version;
Env.report_error err_formatter e; Env.report_error err_formatter e;
eprintf "@]@."; eprintf "@]@.";

View File

@ -21,9 +21,6 @@ open Format
let report_error ppf exn = let report_error ppf exn =
let report ppf = function let report ppf = function
| Env.Error err ->
Location.print_error_cur_file ppf;
Env.report_error ppf err
| Cmi_format.Error err -> | Cmi_format.Error err ->
Location.print_error_cur_file ppf; Location.print_error_cur_file ppf;
Cmi_format.report_error ppf err Cmi_format.report_error ppf err

View File

@ -20,9 +20,6 @@ open Format
let report_error ppf exn = let report_error ppf exn =
let report ppf = function let report ppf = function
| Env.Error err ->
Location.print_error_cur_file ppf;
Env.report_error ppf err
| Cmi_format.Error err -> | Cmi_format.Error err ->
Location.print_error_cur_file ppf; Location.print_error_cur_file ppf;
Cmi_format.report_error ppf err Cmi_format.report_error ppf err

View File

@ -148,7 +148,8 @@ let () =
Location.register_error_of_exn Location.register_error_of_exn
(function (function
| Error (err, file) -> | 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 None
) )

View File

@ -108,9 +108,6 @@ module Sig_analyser = Odoc_sig.Analyser (Odoc_comments.Basic_info_retriever)
differences only concern code generation (i believe).*) differences only concern code generation (i believe).*)
let process_error exn = let process_error exn =
let report ppf = function let report ppf = function
| Env.Error err ->
Location.print_error_cur_file ppf;
Env.report_error ppf err
| Cmi_format.Error err -> | Cmi_format.Error err ->
Location.print_error_cur_file ppf; Location.print_error_cur_file ppf;
Cmi_format.report_error ppf err Cmi_format.report_error ppf err

View File

@ -58,7 +58,9 @@ type error =
| Inconsistent_import of string * string * string | Inconsistent_import of string * string * string
| Need_recursive_types of 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 module EnvLazy : sig
type ('a,'b) t type ('a,'b) t
@ -289,7 +291,7 @@ let check_consistency filename crcs =
(fun (name, crc) -> Consistbl.check crc_units name crc filename) (fun (name, crc) -> Consistbl.check crc_units name crc filename)
crcs crcs
with Consistbl.Inconsistency(name, source, auth) -> 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 *) (* Reading persistent structures from .cmi files *)
@ -310,12 +312,12 @@ let read_pers_struct modname filename = (
ps_filename = filename; ps_filename = filename;
ps_flags = flags } in ps_flags = flags } in
if ps.ps_name <> modname then 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; check_consistency filename ps.ps_crcs;
List.iter List.iter
(function Rectypes -> (function Rectypes ->
if not !Clflags.recursive_types then 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; ps.ps_flags;
Hashtbl.add persistent_structures modname (Some ps); Hashtbl.add persistent_structures modname (Some ps);
ps ps
@ -1603,3 +1605,14 @@ let report_error ppf = function
fprintf ppf fprintf ppf
"@[<hov>Unit %s imports from %s, which uses recursive types.@ %s@]" "@[<hov>Unit %s imports from %s, which uses recursive types.@ %s@]"
export import "The compilation flag -rectypes is required" 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
)

View File

@ -174,7 +174,7 @@ type error =
| Inconsistent_import of string * string * string | Inconsistent_import of string * string * string
| Need_recursive_types of string * string | Need_recursive_types of string * string
exception Error of error exception Error of error * string (* file name *)
open Format open Format