diff options
author | stephentoub <stoub@microsoft.com> | 2016-01-13 13:37:47 -0500 |
---|---|---|
committer | stephentoub <stoub@microsoft.com> | 2016-01-13 17:44:45 -0500 |
commit | 15db7abcb1aaec8f29f0029bc73632494dc281b3 (patch) | |
tree | 5280fa70ae89accedf4f55748ad8bd8846784788 | |
parent | a31dbef16b121d388068f19c73516a611b65cfe8 (diff) | |
download | coreclr-15db7abcb1aaec8f29f0029bc73632494dc281b3.tar.gz coreclr-15db7abcb1aaec8f29f0029bc73632494dc281b3.tar.bz2 coreclr-15db7abcb1aaec8f29f0029bc73632494dc281b3.zip |
Override AggregateException.Message to include more detail
ToString() includes details on inner exceptions, but Message does not, with the default message just saying "One or more errors occurred." This commit overrides Message to append the messages of the inner exceptions as well.
-rw-r--r-- | src/mscorlib/src/System/AggregateException.cs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/mscorlib/src/System/AggregateException.cs b/src/mscorlib/src/System/AggregateException.cs index 025d21cb6b..0c58cb4ed5 100644 --- a/src/mscorlib/src/System/AggregateException.cs +++ b/src/mscorlib/src/System/AggregateException.cs @@ -17,6 +17,7 @@ using System.Globalization; using System.Runtime.ExceptionServices; using System.Runtime.Serialization; using System.Security; +using System.Text; using System.Threading; namespace System @@ -431,6 +432,30 @@ namespace System return new AggregateException(Message, flattenedExceptions); } + /// <summary>Gets a message that describes the exception.</summary> + public override string Message + { + get + { + if (m_innerExceptions.Count == 0) + { + return base.Message; + } + + StringBuilder sb = StringBuilderCache.Acquire(); + sb.Append(base.Message); + sb.Append(' '); + for (int i = 0; i < m_innerExceptions.Count; i++) + { + sb.Append('('); + sb.Append(m_innerExceptions[i].Message); + sb.Append(") "); + } + sb.Length -= 1; + return StringBuilderCache.GetStringAndRelease(sb); + } + } + /// <summary> /// Creates and returns a string representation of the current <see cref="AggregateException"/>. /// </summary> |