XsltException.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // System.Xml.Xsl.XsltException.cs
  3. //
  4. // Authors:
  5. // Tim Coleman ([email protected])
  6. // Andreas Nahr ([email protected])
  7. //
  8. // (C) Copyright 2002 Tim Coleman
  9. // (C) 2003 Andreas Nahr
  10. //
  11. using System;
  12. using System.Runtime.Serialization;
  13. using System.Xml.XPath;
  14. namespace System.Xml.Xsl
  15. {
  16. [Serializable]
  17. public class XsltException : SystemException
  18. {
  19. #region Fields
  20. int lineNumber;
  21. int linePosition;
  22. string sourceUri;
  23. #endregion
  24. #region Constructors
  25. public XsltException (string message, Exception innerException)
  26. : base (message, innerException)
  27. {
  28. // this.message = message;
  29. }
  30. protected XsltException (SerializationInfo info, StreamingContext context)
  31. {
  32. lineNumber = info.GetInt32 ("lineNumber");
  33. linePosition = info.GetInt32 ("linePosition");
  34. sourceUri = info.GetString ("sourceUri");
  35. }
  36. internal XsltException (string message, Exception innerException, int lineNumber, int linePosition, string sourceUri)
  37. : base (message, innerException)
  38. {
  39. this.lineNumber = lineNumber;
  40. this.linePosition = linePosition;
  41. this.sourceUri = sourceUri;
  42. }
  43. internal XsltException (string message, Exception innerException, XPathNavigator nav)
  44. : base (message, innerException)
  45. {
  46. IXmlLineInfo li = nav as IXmlLineInfo;
  47. this.lineNumber = li != null ? li.LineNumber : 0;
  48. this.linePosition = li != null ? li.LinePosition : 0;
  49. this.sourceUri = nav != null ? nav.BaseURI : String.Empty;
  50. }
  51. #endregion
  52. #region Properties
  53. public int LineNumber {
  54. get { return lineNumber; }
  55. }
  56. public int LinePosition {
  57. get { return linePosition; }
  58. }
  59. public override string Message {
  60. get {
  61. string msg = base.Message;
  62. if (sourceUri != null)
  63. msg += " " + sourceUri;
  64. if (lineNumber != 0)
  65. msg += " line " + lineNumber;
  66. if (linePosition != 0)
  67. msg += ", position " + linePosition;
  68. return msg;
  69. }
  70. }
  71. public string SourceUri {
  72. get { return sourceUri; }
  73. }
  74. #endregion
  75. #region Methods
  76. public override void GetObjectData (SerializationInfo info, StreamingContext context)
  77. {
  78. base.GetObjectData (info, context);
  79. info.AddValue ("lineNumber", lineNumber);
  80. info.AddValue ("linePosition", linePosition);
  81. info.AddValue ("sourceUri", sourceUri);
  82. }
  83. #endregion
  84. }
  85. }