ParseException.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. string fileName;
  16. string message;
  17. int line;
  18. int col;
  19. int sourceErrorLine;
  20. public ParseException (string fileName, string message, int line, int col)
  21. : base (message)
  22. {
  23. this.fileName = fileName;
  24. this.message = message;
  25. this.line = line;
  26. this.col = col;
  27. }
  28. public ParseException (string fileName, string message, int line, int col, Exception inner)
  29. : base (message, inner)
  30. {
  31. this.fileName = fileName;
  32. this.message = message;
  33. this.line = line;
  34. this.col = col;
  35. }
  36. public override string Title {
  37. get { return "Parser Error"; }
  38. }
  39. public override string Description {
  40. get {
  41. return "Error parsing a resource required to service this request. " +
  42. "Review your source file and modify it to fix this error.";
  43. }
  44. }
  45. public override string ErrorMessage {
  46. get { return message; }
  47. }
  48. public override string FileName {
  49. get { return fileName; }
  50. }
  51. public override StringReader SourceError {
  52. get {
  53. StreamReader input = new StreamReader (File.OpenRead (fileName));
  54. string result = GetErrorLines (input, line, out sourceErrorLine);
  55. input.Close ();
  56. input = null;
  57. return new StringReader (result);
  58. }
  59. }
  60. public override int SourceErrorLine {
  61. get { return sourceErrorLine; }
  62. }
  63. public override TextReader SourceFile {
  64. get { return null; }
  65. }
  66. }
  67. }