2 // System.Web.Compilation.ParseException
5 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
7 // (C) 2003 Ximian, Inc (http://www.ximian.com)
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System.Runtime.Serialization;
34 using System.Security.Permissions;
36 namespace System.Web.Compilation
39 internal class ParseException : HtmlizedException
44 ParseException (SerializationInfo info, StreamingContext context)
45 : base (info, context)
49 public ParseException (ILocation location, string message)
50 : this (location, message, null)
52 location = new Location (location);
56 public ParseException (ILocation location, string message, Exception inner)
57 : base (message, inner)
59 this.location = location;
62 public override string Title {
63 get { return "Parser Error"; }
66 public override string Description {
68 return "Error parsing a resource required to service this request. " +
69 "Review your source file and modify it to fix this error.";
73 public override string ErrorMessage {
74 get { return Message; }
77 public override string SourceFile {
78 get { return FileName; }
81 public override string FileName {
86 return location.Filename;
90 public override string FileText {
95 string text = location != null ? location.FileText : null;
96 if (text != null && text.Length > 0)
103 using (TextReader reader = new StreamReader (FileName))
104 fileText = reader.ReadToEnd ();
109 public override int [] ErrorLines {
111 if (location == null)
114 return new int [] {location.BeginLine, location.EndLine};
118 public override bool ErrorLinesPaired {
122 [SecurityPermission (SecurityAction.Demand, SerializationFormatter = true)]
123 public override void GetObjectData (SerializationInfo info, StreamingContext ctx)
125 base.GetObjectData (info, ctx);