CompilationException.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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.Collections;
  11. using System.CodeDom.Compiler;
  12. using System.Text;
  13. using System.Web;
  14. namespace System.Web.Compilation
  15. {
  16. internal class CompilationException : HtmlizedException
  17. {
  18. string filename;
  19. CompilerErrorCollection errors;
  20. string fileText;
  21. string errmsg;
  22. int [] errorLines;
  23. public CompilationException (string filename, CompilerErrorCollection errors, string fileText)
  24. {
  25. this.filename = filename;
  26. this.errors = errors;
  27. this.fileText = fileText;
  28. }
  29. public override string SourceFile {
  30. get {
  31. if (errors == null || errors.Count == 0)
  32. return filename;
  33. return errors [0].FileName;
  34. }
  35. }
  36. public override string FileName {
  37. get { return filename; }
  38. }
  39. public override string Title {
  40. get { return "Compilation Error"; }
  41. }
  42. public override string Description {
  43. get {
  44. return "Error compiling a resource required to service this request. " +
  45. "Review your source file and modify it to fix this error.";
  46. }
  47. }
  48. public override string ErrorMessage {
  49. get {
  50. if (errmsg == null && errors != null) {
  51. StringBuilder sb = new StringBuilder ();
  52. foreach (CompilerError err in errors) {
  53. sb.Append (err);
  54. sb.Append ("\n");
  55. }
  56. errmsg = sb.ToString ();
  57. }
  58. return errmsg;
  59. }
  60. }
  61. public override string FileText {
  62. get { return fileText; }
  63. }
  64. public override int [] ErrorLines {
  65. get {
  66. if (errorLines == null && errors != null) {
  67. ArrayList list = new ArrayList ();
  68. foreach (CompilerError err in errors) {
  69. if (err.Line != 0)
  70. list.Add (err.Line);
  71. }
  72. errorLines = (int []) list.ToArray (typeof (int));
  73. Array.Sort (errorLines);
  74. }
  75. return errorLines;
  76. }
  77. }
  78. public override bool ErrorLinesPaired {
  79. get { return false; }
  80. }
  81. }
  82. }