Module of module types for OrderedType,ComparableType,Printable,Serializable,Discrete...
[ocaml.git] / driver / errors.ml
blob56c4e2f3cbad121a8a15c52c67aa093d3d653893
1 (***********************************************************************)
2 (* *)
3 (* Objective Caml *)
4 (* *)
5 (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
6 (* *)
7 (* Copyright 1996 Institut National de Recherche en Informatique et *)
8 (* en Automatique. All rights reserved. This file is distributed *)
9 (* under the terms of the Q Public License version 1.0. *)
10 (* *)
11 (***********************************************************************)
13 (* $Id$ *)
15 (* WARNING: if you change something in this file, you must look at
16 opterrors.ml to see if you need to make the same changes there.
19 open Format
21 (* Report an error *)
23 let report_error ppf exn =
24 let report ppf = function
25 | Lexer.Error(err, loc) ->
26 Location.print ppf loc;
27 Lexer.report_error ppf err
28 | Syntaxerr.Error err ->
29 Syntaxerr.report_error ppf err
30 | Pparse.Error ->
31 fprintf ppf "Preprocessor error"
32 | Env.Error err ->
33 Env.report_error ppf err
34 | Ctype.Tags(l, l') -> fprintf ppf
35 "In this program,@ variant constructors@ `%s and `%s@ \
36 have the same hash value.@ Change one of them." l l'
37 | Typecore.Error(loc, err) ->
38 Location.print ppf loc; Typecore.report_error ppf err
39 | Typetexp.Error(loc, err) ->
40 Location.print ppf loc; Typetexp.report_error ppf err
41 | Typedecl.Error(loc, err) ->
42 Location.print ppf loc; Typedecl.report_error ppf err
43 | Typeclass.Error(loc, err) ->
44 Location.print ppf loc; Typeclass.report_error ppf err
45 | Includemod.Error err ->
46 Includemod.report_error ppf err
47 | Typemod.Error(loc, err) ->
48 Location.print ppf loc; Typemod.report_error ppf err
49 | Translcore.Error(loc, err) ->
50 Location.print ppf loc; Translcore.report_error ppf err
51 | Translclass.Error(loc, err) ->
52 Location.print ppf loc; Translclass.report_error ppf err
53 | Translmod.Error(loc, err) ->
54 Location.print ppf loc; Translmod.report_error ppf err
55 | Symtable.Error code ->
56 Symtable.report_error ppf code
57 | Bytelink.Error code ->
58 Bytelink.report_error ppf code
59 | Bytelibrarian.Error code ->
60 Bytelibrarian.report_error ppf code
61 | Bytepackager.Error code ->
62 Bytepackager.report_error ppf code
63 | Sys_error msg ->
64 fprintf ppf "I/O error: %s" msg
65 | Warnings.Errors (n) ->
66 fprintf ppf "@.Error: error-enabled warnings (%d occurrences)" n
67 | x -> fprintf ppf "@]"; raise x in
69 fprintf ppf "@[%a@]@." report exn