5 // Miguel de Icaza (miguel@ximian.com)
7 // (C) Ximian, Inc. http://www.ximian.com
10 using System.Runtime.Serialization;
11 using System.Reflection;
16 // [ClassInterface (ClassInterfaceType.AutoDual)] (no implementation yet)
18 public class Exception : ISerializable {
19 Exception inner_exception;
23 string stack_trace = "TODO: implement stack traces";
24 string remote_stack_trace = "TODO: Implement remote stack trace";
25 int remote_stack_index;
31 inner_exception = null;
35 public Exception (string msg)
37 inner_exception = null;
41 protected Exception (SerializationInfo info, StreamingContext sc)
44 throw new ArgumentNullException ("info");
46 class_name = info.GetString ("ClassName");
47 message = info.GetString ("Message");
48 inner_exception = (Exception) info.GetValue ("InnerException", typeof (Exception));
49 help_link = info.GetString ("HelpURL");
50 stack_trace = info.GetString ("StackTraceString");
51 remote_stack_trace = info.GetString ("RemoteStackTrace");
52 remote_stack_index = info.GetInt32 ("RemoteStackIndex");
53 hresult = info.GetInt32 ("HResult");
54 source = info.GetString ("Source");
57 public Exception (string msg, Exception e)
63 public Exception InnerException {
65 return inner_exception;
69 public virtual string HelpLink {
79 protected int HResult {
89 public virtual string Message {
96 public virtual string Source {
98 // TODO: if source is null, we must return
99 // the name of the assembly where the error
109 public virtual string StackTrace {
116 public MethodBase TargetSite {
118 // TODO: Implement this.
123 public virtual Exception GetBaseException ()
125 Exception inner = inner_exception;
127 while (inner != null){
128 if (inner.InnerException != null)
129 inner = inner.InnerException;
137 public virtual void GetObjectData (SerializationInfo info, StreamingContext context)
139 info.AddValue ("ClassName", class_name);
140 info.AddValue ("Message", message);
141 info.AddValue ("InnerException", inner_exception);
142 info.AddValue ("HelpURL", help_link);
143 info.AddValue ("StackTraceString", stack_trace);
144 info.AddValue ("RemoteStackTrace", remote_stack_trace);
145 info.AddValue ("RemoteStackIndex", remote_stack_index);
146 info.AddValue ("HResult", hresult);
147 info.AddValue ("Source", source);
150 public override string ToString ()
152 return this.GetType ().FullName + "\n" +
154 GetBaseException ().GetType ().FullName +