* TagAttribute.cs: attributes can be stored as encoded html so we
[mono.git] / mcs / class / System.Web / System.Web.Compilation / CompilationException.cs
1 //
2 // System.Web.Compilation.CompilationException
3 //
4 // Authors:
5 //      Gonzalo Paniagua Javier (gonzalo@ximian.com)
6 //
7 // (C) 2002,2003 Ximian, Inc (http://www.ximian.com)
8 //
9
10 using System;
11 using System.Collections;
12 using System.CodeDom.Compiler;
13 using System.Text;
14 using System.Web;
15
16 namespace System.Web.Compilation
17 {
18         internal class CompilationException : HtmlizedException
19         {
20                 string filename;
21                 CompilerErrorCollection errors;
22                 string fileText;
23                 string errmsg;
24                 int [] errorLines;
25
26                 public CompilationException (string filename, CompilerErrorCollection errors, string fileText)
27                 {
28                         this.filename = filename;
29                         this.errors = errors;
30                         this.fileText = fileText;
31                 }
32
33                 public override string SourceFile {
34                         get {
35                                 if (errors == null || errors.Count == 0)
36                                         return filename;
37
38                                 return errors [0].FileName;
39                         }
40                 }
41                 
42                 public override string FileName {
43                         get { return filename; }
44                 }
45                 
46                 public override string Title {
47                         get { return "Compilation Error"; }
48                 }
49
50                 public override string Description {
51                         get {
52                                 return "Error compiling a resource required to service this request. " +
53                                        "Review your source file and modify it to fix this error.";
54                         }
55                 }
56
57                 public override string ErrorMessage {
58                         get {
59                                 if (errmsg == null && errors != null) {
60                                         StringBuilder sb = new StringBuilder ();
61                                         foreach (CompilerError err in errors) {
62                                                 sb.Append (err);
63                                                 sb.Append ("\n");
64                                         }
65                                         errmsg = sb.ToString ();
66                                 }
67
68                                 return errmsg;
69                         }
70                 }
71
72                 public override string FileText {
73                         get { return fileText; }
74                 }
75
76                 public override int [] ErrorLines {
77                         get {
78                                 if (errorLines == null && errors != null) {
79                                         ArrayList list = new ArrayList ();
80                                         foreach (CompilerError err in errors) {
81                                                 if (err.Line != 0 && !list.Contains (err.Line))
82                                                         list.Add (err.Line);
83                                         }
84                                         errorLines = (int []) list.ToArray (typeof (int));
85                                         Array.Sort (errorLines);
86                                 }
87
88                                 return errorLines;
89                         }
90                 }
91
92                 public override bool ErrorLinesPaired {
93                         get { return false; }
94                 }
95         }
96 }
97