11#if ! NETSTANDARD1_3
22using System ;
3- using System . Runtime . Serialization ;
43using System . Runtime . InteropServices . ComTypes ;
4+ using System . Runtime . Serialization ;
5+ using System . Security . Permissions ;
56
67namespace MsieJavaScriptEngine . ActiveScript
78{
89 [ Serializable ]
910 internal sealed class ActiveScriptException : Exception
1011 {
12+ /// <summary>
13+ /// Error code
14+ /// </summary>
15+ private int _errorCode ;
16+
17+ /// <summary>
18+ /// WCode
19+ /// </summary>
20+ private short _errorWCode ;
21+
22+ /// <summary>
23+ /// Application specific source context
24+ /// </summary>
25+ private uint _sourceContext ;
26+
27+ /// <summary>
28+ /// Subcategory of error
29+ /// </summary>
30+ private string _subcategory = string . Empty ;
31+
32+ /// <summary>
33+ /// Line number on which the error occurred
34+ /// </summary>
35+ private uint _lineNumber ;
36+
37+ /// <summary>
38+ /// Column number on which the error occurred
39+ /// </summary>
40+ private int _columnNumber ;
41+
42+ /// <summary>
43+ /// Content of the line on which the error occurred
44+ /// </summary>
45+ private string _sourceError = string . Empty ;
46+
1147 /// <summary>
1248 /// Gets or sets a error code
1349 /// </summary>
1450 public int ErrorCode
1551 {
16- get ;
17- set ;
52+ get { return _errorCode ; }
53+ set { _errorCode = value ; }
1854 }
1955
2056 /// <summary>
2157 /// Gets or sets a WCode
2258 /// </summary>
2359 public short ErrorWCode
2460 {
25- get ;
26- set ;
61+ get { return _errorWCode ; }
62+ set { _errorWCode = value ; }
2763 }
2864
2965 /// <summary>
3066 /// Gets or sets a application specific source context
3167 /// </summary>
3268 public uint SourceContext
3369 {
34- get ;
35- set ;
70+ get { return _sourceContext ; }
71+ set { _sourceContext = value ; }
3672 }
3773
3874 /// <summary>
3975 /// Gets or sets a subcategory of error
4076 /// </summary>
4177 public string Subcategory
4278 {
43- get ;
44- set ;
79+ get { return _subcategory ; }
80+ set { _subcategory = value ; }
4581 }
4682
4783 /// <summary>
4884 /// Gets or sets a line number on which the error occurred
4985 /// </summary>
5086 public uint LineNumber
5187 {
52- get ;
53- set ;
88+ get { return _lineNumber ; }
89+ set { _lineNumber = value ; }
5490 }
5591
5692 /// <summary>
5793 /// Gets or sets a column number on which the error occurred
5894 /// </summary>
5995 public int ColumnNumber
6096 {
61- get ;
62- set ;
97+ get { return _columnNumber ; }
98+ set { _columnNumber = value ; }
6399 }
64100
65101 /// <summary>
66102 /// Gets or sets a content of the line on which the error occurred
67103 /// </summary>
68104 public string SourceError
69105 {
70- get ;
71- set ;
106+ get { return _sourceError ; }
107+ set { _sourceError = value ; }
72108 }
73109
74110
75111 /// <summary>
76112 /// Initializes a new instance of the <see cref="ActiveScriptException"/> class
77- /// </summary>
78- public ActiveScriptException ( )
79- { }
80-
81- /// <summary>
82- /// Initializes a new instance of the <see cref="ActiveScriptException"/> class
113+ /// with a specified error message
83114 /// </summary>
84115 /// <param name="message">The message</param>
85116 public ActiveScriptException ( string message )
@@ -88,14 +119,8 @@ public ActiveScriptException(string message)
88119
89120 /// <summary>
90121 /// Initializes a new instance of the <see cref="ActiveScriptException"/> class
91- /// </summary>
92- /// <param name="innerException">The inner exception</param>
93- public ActiveScriptException ( Exception innerException )
94- : base ( null , innerException )
95- { }
96-
97- /// <summary>
98- /// Initializes a new instance of the <see cref="ActiveScriptException"/> class
122+ /// with a specified error message and a reference to the inner exception
123+ /// that is the cause of this exception
99124 /// </summary>
100125 /// <param name="message">The message</param>
101126 /// <param name="innerException">The inner exception</param>
@@ -104,21 +129,24 @@ public ActiveScriptException(string message, Exception innerException)
104129 { }
105130
106131 /// <summary>
107- /// Initializes a new instance of the <see cref="ActiveScriptException"/> class
132+ /// Initializes a new instance of the <see cref="ActiveScriptException"/> class with serialized data
108133 /// </summary>
109- /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/>
110- /// that holds the serialized object data about the exception being thrown</param>
111- /// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/>
112- /// that contains contextual information about the source or destination</param>
113- /// <exception cref="T:System.ArgumentNullException">
114- /// The <paramref name="info"/> parameter is null
115- /// </exception>
116- /// <exception cref="T:System.Runtime.Serialization.SerializationException">
117- /// The class name is null or <see cref="P:System.Exception.HResult"/> is zero (0)
118- /// </exception>
134+ /// <param name="info">The object that holds the serialized data</param>
135+ /// <param name="context">The contextual information about the source or destination</param>
119136 private ActiveScriptException ( SerializationInfo info , StreamingContext context )
120137 : base ( info , context )
121- { }
138+ {
139+ if ( info != null )
140+ {
141+ _errorCode = info . GetInt32 ( "ErrorCode" ) ;
142+ _errorWCode = info . GetInt16 ( "ErrorWCode" ) ;
143+ _sourceContext = info . GetUInt32 ( "SourceContext" ) ;
144+ _subcategory = info . GetString ( "Subcategory" ) ;
145+ _lineNumber = info . GetUInt32 ( "LineNumber" ) ;
146+ _columnNumber = info . GetInt32 ( "ColumnNumber" ) ;
147+ _sourceError = info . GetString ( "SourceError" ) ;
148+ }
149+ }
122150
123151
124152 internal static ActiveScriptException Create ( IActiveScriptError error )
@@ -191,6 +219,33 @@ internal static ActiveScriptException Create(IActiveScriptError error)
191219
192220 return activeScriptException ;
193221 }
222+
223+ #region Exception overrides
224+
225+ /// <summary>
226+ /// Populates a <see cref="SerializationInfo"/> with the data needed to serialize the target object
227+ /// </summary>
228+ /// <param name="info">The <see cref="SerializationInfo"/> to populate with data</param>
229+ /// <param name="context">The destination (see <see cref="StreamingContext"/>) for this serialization</param>
230+ [ SecurityPermission ( SecurityAction . Demand , SerializationFormatter = true ) ]
231+ public override void GetObjectData ( SerializationInfo info , StreamingContext context )
232+ {
233+ if ( info == null )
234+ {
235+ throw new ArgumentNullException ( "info" ) ;
236+ }
237+
238+ base . GetObjectData ( info , context ) ;
239+ info . AddValue ( "ErrorCode" , _errorCode ) ;
240+ info . AddValue ( "ErrorWCode" , _errorWCode ) ;
241+ info . AddValue ( "SourceContext" , _sourceContext ) ;
242+ info . AddValue ( "Subcategory" , _subcategory ) ;
243+ info . AddValue ( "LineNumber" , _lineNumber ) ;
244+ info . AddValue ( "ColumnNumber" , _columnNumber ) ;
245+ info . AddValue ( "SourceError" , _sourceError ) ;
246+ }
247+
248+ #endregion
194249 }
195250}
196251#endif
0 commit comments