ParseException.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //
  2. // System.Web.Compilation.ParseException
  3. //
  4. // Authors:
  5. // Gonzalo Paniagua Javier ([email protected])
  6. //
  7. // (C) 2003 Ximian, Inc (http://www.ximian.com)
  8. //
  9. using System;
  10. using System.IO;
  11. namespace System.Web.Compilation
  12. {
  13. internal class ParseException : HtmlizedException
  14. {
  15. ILocation location;
  16. string fileText;
  17. public ParseException (ILocation location, string message)
  18. : this (location, message, null)
  19. {
  20. location = new Location (location);
  21. }
  22. public ParseException (ILocation location, string message, Exception inner)
  23. : base (message, inner)
  24. {
  25. this.location = location;
  26. }
  27. public override string Title {
  28. get { return "Parser Error"; }
  29. }
  30. public override string Description {
  31. get {
  32. return "Error parsing a resource required to service this request. " +
  33. "Review your source file and modify it to fix this error.";
  34. }
  35. }
  36. public override string ErrorMessage {
  37. get { return Message; }
  38. }
  39. public override string SourceFile {
  40. get { return FileName; }
  41. }
  42. public override string FileName {
  43. get {
  44. if (location == null)
  45. return null;
  46. return location.Filename;
  47. }
  48. }
  49. public override string FileText {
  50. get {
  51. if (fileText != null)
  52. return fileText;
  53. if (FileName == null)
  54. return null;
  55. //FIXME: encoding
  56. TextReader reader = new StreamReader (FileName);
  57. fileText = reader.ReadToEnd ();
  58. return fileText;
  59. }
  60. }
  61. public override int [] ErrorLines {
  62. get {
  63. if (location == null)
  64. return null;
  65. return new int [] {location.BeginLine, location.EndLine};
  66. }
  67. }
  68. public override bool ErrorLinesPaired {
  69. get { return true; }
  70. }
  71. }
  72. }