diff --git a/compiler/catala_utils/message.ml b/compiler/catala_utils/message.ml index 5886a446..460ae4ff 100644 --- a/compiler/catala_utils/message.ml +++ b/compiler/catala_utils/message.ml @@ -227,98 +227,6 @@ exception CompilerError of Content.t (** {1 Error printing} *) -let raise_spanned_error - ?(span_msg : Content.message option) - ?(suggestion = ([] : string list)) - (span : Pos.t) - format = - let continuation (message : Format.formatter -> unit) = - raise - (CompilerError - ([MainMessage message; Position { pos_message = span_msg; pos = span }] - @ match suggestion with [] -> [] | sugg -> [Suggestion sugg])) - in - Format.kdprintf continuation format - -let raise_multispanned_error_full - ?(suggestion = ([] : string list)) - (spans : (Content.message option * Pos.t) list) - format = - Format.kdprintf - (fun message -> - raise - (CompilerError - (MainMessage message - :: List.map - (fun (pos_message, pos) -> Position { pos_message; pos }) - spans - @ match suggestion with [] -> [] | sugg -> [Suggestion sugg]))) - format - -let raise_multispanned_error - ?(suggestion = ([] : string list)) - (spans : (string option * Pos.t) list) - format = - raise_multispanned_error_full ~suggestion - (List.map - (fun (msg, pos) -> - Option.map (fun s ppf -> Format.pp_print_string ppf s) msg, pos) - spans) - format - -let raise_error format = - Format.kdprintf - (fun message -> raise (CompilerError [MainMessage message])) - format - -let raise_internal_error format = - Format.kdprintf - (fun message -> - raise (CompilerError (Content.to_internal_error [MainMessage message]))) - format - -(** {1 Warning printing}*) - -let assert_internal_error condition fmt = - if condition then raise_internal_error ("assertion failed: " ^^ fmt) - else Format.ifprintf (Format.formatter_of_out_channel stdout) fmt - -let emit_multispanned_warning - (pos : (Content.message option * Pos.t) list) - format = - Format.kdprintf - (fun message -> - Content.emit - (MainMessage message - :: List.map - (fun (pos_message, pos) -> Position { pos_message; pos }) - pos) - Warning) - format - -let emit_spanned_warning - ?(span_msg : Content.message option) - (span : Pos.t) - format = - emit_multispanned_warning [span_msg, span] format - -let emit_warning format = emit_multispanned_warning [] format - -let emit_log format = - Format.kdprintf (fun message -> Content.emit [MainMessage message] Log) format - -let emit_debug format = - Format.kdprintf - (fun message -> Content.emit [MainMessage message] Debug) - format - -let emit_result format = - Format.kdprintf - (fun message -> Content.emit [MainMessage message] Result) - format - -(** New concise interface *) - type ('a, 'b) emitter = ?header:Content.message -> ?internal:bool -> diff --git a/compiler/catala_utils/message.mli b/compiler/catala_utils/message.mli index bcef9d12..cb16d658 100644 --- a/compiler/catala_utils/message.mli +++ b/compiler/catala_utils/message.mli @@ -64,60 +64,6 @@ end exception CompilerError of Content.t -(** {1 Common error raising} *) - -val raise_spanned_error : - ?span_msg:Content.message -> - ?suggestion:string list -> - Pos.t -> - ('a, Format.formatter, unit, 'b) format4 -> - 'a - -val raise_multispanned_error_full : - ?suggestion:string list -> - (Content.message option * Pos.t) list -> - ('a, Format.formatter, unit, 'b) format4 -> - 'a - -val raise_multispanned_error : - ?suggestion:string list -> - (string option * Pos.t) list -> - ('a, Format.formatter, unit, 'b) format4 -> - 'a - -val raise_error : ('a, Format.formatter, unit, 'b) format4 -> 'a -val raise_internal_error : ('a, Format.formatter, unit, 'b) format4 -> 'a - -val assert_internal_error : - bool -> ('a, Format.formatter, unit, unit, unit, unit) format6 -> 'a - -(** {1 Common warning emission}*) - -val emit_multispanned_warning : - (Content.message option * Pos.t) list -> - ('a, Format.formatter, unit) format -> - 'a - -val emit_spanned_warning : - ?span_msg:Content.message -> - Pos.t -> - ('a, Format.formatter, unit) format -> - 'a - -val emit_warning : ('a, Format.formatter, unit) format -> 'a - -(** {1 Common log emission}*) - -val emit_log : ('a, Format.formatter, unit) format -> 'a - -(** {1 Common debug emission}*) - -val emit_debug : ('a, Format.formatter, unit) format -> 'a - -(** {1 Common result emission}*) - -val emit_result : ('a, Format.formatter, unit) format -> 'a - (** {1 Some formatting helpers}*) val unformat : (Format.formatter -> unit) -> string @@ -133,7 +79,7 @@ val formatter_of_out_channel : out_channel -> Format.formatter the ocolor tags. Actual use of escape codes in the output depends on [Cli.style_flag] -- and wether the channel is a tty if that is set to auto. *) -(** {1 New concise interface using optional args} *) +(** {1 Simple interface for various message emission} *) type ('a, 'b) emitter = ?header:Content.message ->