2 // report.cs: report errors and warnings.
4 // Author: Miguel de Icaza (miguel@ximian.com)
6 // (C) 2001 Ximian, Inc. (http://www.ximian.com)
18 // whether errors are fatal (they throw an exception), useful
19 // for debugging the compiler
24 // If the error code is reported on the given line,
25 // then the process exits with a unique error code.
27 // Used for the test suite to excercise the error codes
29 static int probe_error = 0;
30 static int probe_line = 0;
32 static void Check (int code)
34 if (code == probe_error){
35 Environment.Exit (123);
39 static public void RealError (string msg)
42 Console.WriteLine (msg);
45 throw new Exception (msg);
48 static public void Error (int code, Location l, string text)
50 string msg = l.Name + "(" + l.Row +
51 "): Error CS"+code+": " + text;
57 static public void Warning (int code, Location l, string text)
59 Console.WriteLine (l.Name + "(" + l.Row +
60 "): Warning CS"+code+": " + text);
65 static public void Error (int code, string text)
67 string msg = "Error CS"+code+": "+text;
73 static public void Warning (int code, string text)
75 Console.WriteLine ("Warning CS"+code+": "+text);
80 static public void Message (Message m)
82 if (m is ErrorMessage)
83 Error (m.code, m.text);
85 Warning (m.code, m.text);
88 static public void SetProbe (int code, int line)
94 static public int ProbeCode {
100 static public int Errors {
106 static public int Warnings {
112 static public bool Fatal {
123 public class Message {
127 public Message (int code, string text)
134 public class WarningMessage : Message {
135 public WarningMessage (int code, string text) : base (code, text)
140 public class ErrorMessage : Message {
141 public ErrorMessage (int code, string text) : base (code, text)
146 // For compatibility reasons with old code.
148 public static void report_error (string error)
150 Console.Write ("ERROR: ");
151 Console.WriteLine (error);