Replace all code_errorf with code_error
This commit is contained in:
parent
59eda906b0
commit
9aa827ac35
|
@ -62,12 +62,16 @@ module Repr = struct
|
||||||
let get_if_file_exists_exn state =
|
let get_if_file_exists_exn state =
|
||||||
match !state with
|
match !state with
|
||||||
| Decided (_, t) -> t
|
| Decided (_, t) -> t
|
||||||
| Undecided _ -> code_errorf "Build.get_if_file_exists_exn: got undecided"
|
| Undecided _ ->
|
||||||
|
Exn.code_error "Build.get_if_file_exists_exn: got undecided" []
|
||||||
|
|
||||||
let get_glob_result_exn state =
|
let get_glob_result_exn state =
|
||||||
match !state with
|
match !state with
|
||||||
| G_evaluated l -> l
|
| G_evaluated l -> l
|
||||||
| G_unevaluated _ -> code_errorf "Build.get_glob_result_exn: got unevaluated"
|
| G_unevaluated (loc, path, _) ->
|
||||||
|
Exn.code_error "Build.get_glob_result_exn: got unevaluated"
|
||||||
|
[ "loc", Loc.sexp_of_t loc
|
||||||
|
; "path", Path.sexp_of_t path ]
|
||||||
end
|
end
|
||||||
include Repr
|
include Repr
|
||||||
let repr t = t
|
let repr t = t
|
||||||
|
|
|
@ -169,13 +169,19 @@ let targets =
|
||||||
| Fail _ -> acc
|
| Fail _ -> acc
|
||||||
| If_file_exists (_, state) -> begin
|
| If_file_exists (_, state) -> begin
|
||||||
match !state with
|
match !state with
|
||||||
| Decided _ -> code_errorf "Build_interpret.targets got decided if_file_exists"
|
| Decided (v, _) ->
|
||||||
|
Exn.code_error "Build_interpret.targets got decided if_file_exists"
|
||||||
|
["exists", Sexp.To_sexp.bool v]
|
||||||
| Undecided (a, b) ->
|
| Undecided (a, b) ->
|
||||||
match loop a [], loop b [] with
|
match loop a [], loop b [] with
|
||||||
| [], [] -> acc
|
| [], [] -> acc
|
||||||
| _ ->
|
| a, b ->
|
||||||
code_errorf "Build_interpret.targets: cannot have targets \
|
let targets x = Path.Set.sexp_of_t (Target.paths x) in
|
||||||
under a [if_file_exists]"
|
Exn.code_error "Build_interpret.targets: cannot have targets \
|
||||||
|
under a [if_file_exists]"
|
||||||
|
[ "targets-a", targets a
|
||||||
|
; "targets-b", targets b
|
||||||
|
]
|
||||||
end
|
end
|
||||||
| Memo m -> loop m.t acc
|
| Memo m -> loop m.t acc
|
||||||
| Catch (t, _) -> loop t acc
|
| Catch (t, _) -> loop t acc
|
||||||
|
|
|
@ -407,9 +407,11 @@ let entry_point t ~f =
|
||||||
(match t.load_dir_stack with
|
(match t.load_dir_stack with
|
||||||
| [] ->
|
| [] ->
|
||||||
()
|
()
|
||||||
| _ :: _ ->
|
| stack ->
|
||||||
code_errorf
|
Exn.code_error
|
||||||
"Build_system.entry_point: called inside the rule generator callback");
|
"Build_system.entry_point: called inside the rule generator callback"
|
||||||
|
["stack", Sexp.To_sexp.list Path.sexp_of_t stack]
|
||||||
|
);
|
||||||
f ()
|
f ()
|
||||||
|
|
||||||
module Target = Build_interpret.Target
|
module Target = Build_interpret.Target
|
||||||
|
|
|
@ -12,8 +12,5 @@ let kerrf fmt ~f =
|
||||||
f s)
|
f s)
|
||||||
err_ppf fmt
|
err_ppf fmt
|
||||||
|
|
||||||
let code_errorf fmt =
|
|
||||||
kerrf fmt ~f:(fun s -> Stdune.Exn.code_error s [])
|
|
||||||
|
|
||||||
let die fmt =
|
let die fmt =
|
||||||
kerrf fmt ~f:(fun s -> raise (Fatal_error s))
|
kerrf fmt ~f:(fun s -> raise (Fatal_error s))
|
||||||
|
|
|
@ -22,9 +22,6 @@ exception Already_reported
|
||||||
(** Raise a [Fatal_error] exception *)
|
(** Raise a [Fatal_error] exception *)
|
||||||
val die : ('a, Format.formatter, unit, 'b) format4 -> 'a
|
val die : ('a, Format.formatter, unit, 'b) format4 -> 'a
|
||||||
|
|
||||||
(** Raise a [Code_error] exception *)
|
|
||||||
val code_errorf : ('a, Format.formatter, unit, 'b) format4 -> 'a
|
|
||||||
|
|
||||||
(**/**)
|
(**/**)
|
||||||
(* Referenced in Ansi_color and Report_error *)
|
(* Referenced in Ansi_color and Report_error *)
|
||||||
val err_buf : Buffer.t
|
val err_buf : Buffer.t
|
||||||
|
|
|
@ -31,7 +31,8 @@ module File = struct
|
||||||
|
|
||||||
let to_ocaml t =
|
let to_ocaml t =
|
||||||
match t.syntax with
|
match t.syntax with
|
||||||
| OCaml -> code_errorf "to_ocaml: can only convert reason Files" ()
|
| OCaml -> Exn.code_error "to_ocaml: can only convert reason Files"
|
||||||
|
["t.name", Sexp.To_sexp.string t.name]
|
||||||
| Reason ->
|
| Reason ->
|
||||||
{ syntax = OCaml
|
{ syntax = OCaml
|
||||||
; name =
|
; name =
|
||||||
|
@ -40,7 +41,9 @@ module File = struct
|
||||||
(match Filename.extension t.name with
|
(match Filename.extension t.name with
|
||||||
| ".re" -> ".ml"
|
| ".re" -> ".ml"
|
||||||
| ".rei" -> ".mli"
|
| ".rei" -> ".mli"
|
||||||
| _ -> code_errorf "to_ocaml: unrecognized extension %s" ext ())
|
| _ -> Exn.code_error "to_ocaml: unrecognized extension"
|
||||||
|
[ "name", Sexp.To_sexp.string t.name
|
||||||
|
; "ext", Sexp.To_sexp.string ext ])
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ module Local = struct
|
||||||
|
|
||||||
let parent = function
|
let parent = function
|
||||||
| "" ->
|
| "" ->
|
||||||
code_errorf "Path.Local.parent called on the root"
|
Exn.code_error "Path.Local.parent called on the root" []
|
||||||
| t ->
|
| t ->
|
||||||
match String.rindex_from t (String.length t - 1) '/' with
|
match String.rindex_from t (String.length t - 1) '/' with
|
||||||
| exception Not_found -> ""
|
| exception Not_found -> ""
|
||||||
|
@ -86,7 +86,7 @@ module Local = struct
|
||||||
|
|
||||||
let basename = function
|
let basename = function
|
||||||
| "" ->
|
| "" ->
|
||||||
code_errorf "Path.Local.basename called on the root"
|
Exn.code_error "Path.Local.basename called on the root" []
|
||||||
| t ->
|
| t ->
|
||||||
let len = String.length t in
|
let len = String.length t in
|
||||||
match String.rindex_from t (len - 1) '/' with
|
match String.rindex_from t (len - 1) '/' with
|
||||||
|
|
Loading…
Reference in New Issue