2
0

CompilationException.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // System.Web.Compilation.CompilationException
  3. //
  4. // Authors:
  5. // Gonzalo Paniagua Javier ([email protected])
  6. //
  7. // (C) 2002,2003 Ximian, Inc (http://www.ximian.com)
  8. //
  9. using System;
  10. using System.Web;
  11. using System.IO;
  12. namespace System.Web.Compilation
  13. {
  14. internal class CompilationException : HtmlizedException
  15. {
  16. CompilationResult result;
  17. public CompilationException (CompilationResult result)
  18. : base ("Compilation Error")
  19. {
  20. this.result = result;
  21. }
  22. public CompilationException (string msg, CompilationResult result)
  23. : base (msg)
  24. {
  25. this.result = result;
  26. }
  27. public CompilationException (CompilationCacheItem item)
  28. {
  29. this.result = item.Result;
  30. }
  31. public override string FileName {
  32. get { return result.FileName; }
  33. }
  34. public override string Title {
  35. get { return "Compilation Error"; }
  36. }
  37. public override string Description {
  38. get {
  39. return "Error compiling a resource required to service this request. " +
  40. "Review your source file and modify it to fix this error.";
  41. }
  42. }
  43. public override string ErrorMessage {
  44. get {
  45. //FIXME: it should be a one line message.
  46. return result.CompilerOutput;
  47. }
  48. }
  49. //TODO: get lines from compiler output.
  50. public override StringReader SourceError { get {return null;}}
  51. public override int SourceErrorLine { get { return 0; } }
  52. public override TextReader SourceFile {
  53. get {
  54. StreamReader input = new StreamReader (File.OpenRead (FileName));
  55. int sourceErrorLine;
  56. string result = GetErrorLines (input, 0, out sourceErrorLine);
  57. input.Close ();
  58. input = null;
  59. return new StringReader (result);
  60. }
  61. }
  62. }
  63. }