diff options
Diffstat (limited to 'driver/errors.ml')
-rw-r--r-- | driver/errors.ml | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/driver/errors.ml b/driver/errors.ml index ebb3dcecc..8f877a45f 100644 --- a/driver/errors.ml +++ b/driver/errors.ml @@ -14,48 +14,47 @@ (* Error report *) -open Formatmsg +open Format open Location (* Report an error *) -let report_error exn = - open_box 0; - begin match exn with - Lexer.Error(err, start, stop) -> - Location.print {loc_start = start; loc_end = stop; loc_ghost = false}; - Lexer.report_error err +let report_error ppf exn = + let report ppf = function + | Lexer.Error(err, start, stop) -> + Location.print ppf {loc_start = start; loc_end = stop; loc_ghost = false}; + Lexer.report_error ppf err | Syntaxerr.Error err -> - Syntaxerr.report_error err + Syntaxerr.report_error ppf err | Env.Error err -> - Env.report_error err - | Ctype.Tags(l, l') -> - printf "In this program,@ variant constructors@ `%s and `%s@ have same hash value." l l' + Env.report_error ppf err + | Ctype.Tags(l, l') -> fprintf ppf + "In this program,@ variant constructors@ `%s and `%s@ \ + have the same hash value." l l' | Typecore.Error(loc, err) -> - Location.print loc; Typecore.report_error err + Location.print ppf loc; Typecore.report_error ppf err | Typetexp.Error(loc, err) -> - Location.print loc; Typetexp.report_error err + Location.print ppf loc; Typetexp.report_error ppf err | Typedecl.Error(loc, err) -> - Location.print loc; Typedecl.report_error err + Location.print ppf loc; Typedecl.report_error ppf err | Includemod.Error err -> - Includemod.report_error err + Includemod.report_error ppf err | Typemod.Error(loc, err) -> - Location.print loc; Typemod.report_error err + Location.print ppf loc; Typemod.report_error ppf err | Translcore.Error(loc, err) -> - Location.print loc; Translcore.report_error err + Location.print ppf loc; Translcore.report_error ppf err | Symtable.Error code -> - Symtable.report_error code + Symtable.report_error ppf code | Bytelink.Error code -> - Bytelink.report_error code + Bytelink.report_error ppf code | Bytelibrarian.Error code -> - Bytelibrarian.report_error code + Bytelibrarian.report_error ppf code | Sys_error msg -> - printf "I/O error: %s" msg + fprintf ppf "I/O error: %s" msg | Typeclass.Error(loc, err) -> - Location.print loc; Typeclass.report_error err + Location.print ppf loc; Typeclass.report_error ppf err | Translclass.Error(loc, err) -> - Location.print loc; Translclass.report_error err - | x -> - close_box(); raise x - end; - close_box(); print_newline() + Location.print ppf loc; Translclass.report_error ppf err + | x -> close_box(); raise x in + + fprintf ppf "@[%a@]@." report exn |