2 // report.cs: report errors and warnings.
4 // Author: Miguel de Icaza (miguel@ximian.com)
6 // (C) 2001 Ximian, Inc. (http://www.ximian.com)
11 namespace Mono.CSharp {
14 /// This class is used to report errors and warnings t te user.
20 // whether errors are fatal (they throw an exception), useful
21 // for debugging the compiler
25 // If the error code is reported on the given line,
26 // then the process exits with a unique error code.
28 // Used for the test suite to excercise the error codes
30 static int probe_error = 0;
31 static int probe_line = 0;
33 static void Check (int code)
35 if (code == probe_error){
36 Environment.Exit (123);
40 static public void RealError (string msg)
43 Console.WriteLine (msg);
46 throw new Exception (msg);
49 static public void Error (int code, Location l, string text)
51 string msg = l.Name + "(" + l.Row +
52 "): Error CS"+code+": " + text;
58 static public void Warning (int code, Location l, string text)
60 Console.WriteLine (l.Name + "(" + l.Row +
61 "): Warning CS"+code+": " + text);
66 static public void Error (int code, string text)
68 string msg = "Error CS"+code+": "+text;
74 static public void Warning (int code, string text)
76 Console.WriteLine ("Warning CS"+code+": "+text);
81 static public void Message (Message m)
83 if (m is ErrorMessage)
84 Error (m.code, m.text);
86 Warning (m.code, m.text);
89 static public void SetProbe (int code, int line)
95 static public int ProbeCode {
101 static public int Errors {
107 static public int Warnings {
113 static public bool Fatal {
124 public class Message {
128 public Message (int code, string text)
135 public class WarningMessage : Message {
136 public WarningMessage (int code, string text) : base (code, text)
141 public class ErrorMessage : Message {
142 public ErrorMessage (int code, string text) : base (code, text)
147 // For compatibility reasons with old code.
149 public static void report_error (string error)
151 Console.Write ("ERROR: ");
152 Console.WriteLine (error);