[sledge] Use the configured margin when formatting failure messages

Reviewed By: bennostein

Differential Revision: D17801934

fbshipit-source-id: af7acec9b
master
Josh Berdine 5 years ago committed by Facebook Github Bot
parent a386b36616
commit 6120b7d098

@ -65,9 +65,14 @@ let warn fmt =
Format.pp_force_newline fs () ) Format.pp_force_newline fs () )
fs fmt fs fmt
let raisef exn fmt = let raisef ?margin exn fmt =
let bt = Caml.Printexc.get_raw_backtrace () in let bt = Caml.Printexc.get_raw_backtrace () in
let fs = Format.str_formatter in let fs = Format.str_formatter in
( match margin with
| Some m ->
Format.pp_set_margin fs m ;
Format.pp_set_max_indent fs (m - 1)
| None -> () ) ;
Format.pp_open_box fs 2 ; Format.pp_open_box fs 2 ;
Format.kfprintf Format.kfprintf
(fun fs () -> (fun fs () ->

@ -77,7 +77,7 @@ type ('a, 'b) fmt = ('a, Formatter.t, unit, 'b) format4
exception Unimplemented of string exception Unimplemented of string
val raisef : (string -> exn) -> ('a, unit -> _) fmt -> 'a val raisef : ?margin:int -> (string -> exn) -> ('a, unit -> _) fmt -> 'a
(** Take a function from a string message to an exception, and a format (** Take a function from a string message to an exception, and a format
string with the additional arguments it specifies, and then call the string with the additional arguments it specifies, and then call the
function on the formatted string and raise the returned exception. *) function on the formatted string and raise the returned exception. *)

@ -167,7 +167,8 @@ let retn mod_name fun_name k result =
result result
let fail fmt = let fail fmt =
raisef let margin = Format.pp_get_margin fs () in
raisef ~margin
(fun msg -> (fun msg ->
Format.fprintf fs "@\n@[<2>| %s@]@." msg ; Format.fprintf fs "@\n@[<2>| %s@]@." msg ;
Failure msg ) Failure msg )

Loading…
Cancel
Save