1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
8
/// <summary> This convenience class provides access to an exception within the debugee. </summary>
9
/// <seealso cref="System.Exception" />
10
public class Exception: DebuggerObject
15
get { return exception; }
18
public Exception(Value exception)
20
this.exception = exception;
23
/// <summary> The <c>GetType().FullName</c> of the exception. </summary>
24
/// <seealso cref="System.Exception" />
27
return exception.Type.FullName;
31
/// <summary> The <c>Message</c> property of the exception. </summary>
32
/// <seealso cref="System.Exception" />
33
public string Message {
35
Value message = exception.GetMemberValue("_message");
36
return message.IsNull ? string.Empty : message.AsString();
40
/// <summary> The <c>InnerException</c> property of the exception. </summary>
41
/// <seealso cref="System.Exception" />
42
public Exception InnerException {
44
Value innerException = exception.GetMemberValue("_innerException");
45
return innerException.IsNull ? null : new Exception(innerException);
49
public void MakeValuePermanent()
51
exception = exception.GetPermanentReference();
54
public override string ToString()
56
StringBuilder sb = new StringBuilder();
58
if (!string.IsNullOrEmpty(this.Message)) {
60
sb.Append(this.Message);
62
if (this.InnerException != null) {
64
sb.Append(this.InnerException.ToString());
69
public string GetStackTrace()
71
return GetStackTrace("--- End of inner exception stack trace ---");
74
/// <summary> Returs formated stacktrace for the exception </summary>
75
/// <exception cref="GetValueException"> Getting the stacktrace involves property
76
/// evaluation so GetValueException can be thrown in some cicumstances. </exception>
77
public string GetStackTrace(string endOfInnerExceptionFormat)
79
StringBuilder sb = new StringBuilder();
80
if (this.InnerException != null) {
81
sb.Append(this.InnerException.GetStackTrace(endOfInnerExceptionFormat));
83
sb.Append(endOfInnerExceptionFormat);
86
// Note that evaluation is not possible after a stackoverflow exception
87
Value stackTrace = exception.GetMemberValue("StackTrace");
88
if (!stackTrace.IsNull) {
89
sb.Append(stackTrace.AsString());
96
public class ExceptionEventArgs: ProcessEventArgs
98
readonly Exception exception;
99
readonly ExceptionType exceptionType;
100
readonly bool isUnhandled;
102
public Exception Exception {
103
get { return exception; }
106
public ExceptionType ExceptionType {
107
get { return exceptionType; }
110
public bool IsUnhandled {
111
get { return isUnhandled; }
114
public ExceptionEventArgs(Process process, Exception exception, ExceptionType exceptionType, bool isUnhandled):base(process)
116
this.exception = exception;
117
this.exceptionType = exceptionType;
118
this.isUnhandled = isUnhandled;