2003-03-24 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / class / System.Web / System.Web.Compilation / ParseException.cs
1 //
2 // System.Web.Compilation.ParseException
3 //
4 // Authors:
5 //      Gonzalo Paniagua Javier (gonzalo@ximian.com)
6 //
7 // (C) 2003 Ximian, Inc (http://www.ximian.com)
8 //
9
10 using System;
11 using System.IO;
12
13 namespace System.Web.Compilation
14 {
15         internal class ParseException : HtmlizedException
16         {
17                 string fileName;
18                 string message;
19                 int line;
20                 int col;
21                 int sourceErrorLine;
22
23                 public ParseException (string fileName, string message, int line, int col)
24                         : base (message)
25                 {
26                         this.fileName = fileName;
27                         this.message = message;
28                         this.line = line >= 1 ? line : 1;
29                         this.col = col;
30                 }
31                 
32                 public ParseException (string fileName, string message, int line, int col, Exception inner)
33                         : base (message, inner)
34                 {
35                         this.fileName = fileName;
36                         this.message = message;
37                         this.line = line >= 1 ? line : 1;
38                         this.col = col;
39                 }
40
41                 public override string Title {
42                         get { return "Parser Error"; }
43                 }
44
45                 public override string Description {
46                         get {
47                                 return "Error parsing a resource required to service this request. " +
48                                        "Review your source file and modify it to fix this error.";
49                         }
50                 }
51
52                 public override string ErrorMessage {
53                         get { return message; }
54                 }
55
56                 public override string FileName {
57                         get { return fileName; }
58                 }
59                 
60                 public override StringReader SourceError {
61                         get {
62                                 StreamReader input = new StreamReader (File.OpenRead (fileName));
63                                 string result = GetErrorLines (input, line - 1, out sourceErrorLine);
64                                 input.Close ();
65                                 input = null;
66                                 return new StringReader (result);
67                         }
68                 }
69
70                 public override int SourceErrorLine {
71                         get { return sourceErrorLine; }
72                 }
73
74                 public override TextReader SourceFile {
75                         get { return null; }
76                 }
77         }
78 }
79