Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
AggregateException.cs
Go to the documentation of this file.
8using System.Text;
9
10namespace System;
11
13[DebuggerDisplay("Count = {InnerExceptionCount}")]
14[TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
16{
17 private readonly Exception[] _innerExceptions;
18
20
22
23 public override string Message
24 {
25 get
26 {
27 if (_innerExceptions.Length == 0)
28 {
29 return base.Message;
30 }
32 stringBuilder.Append(base.Message);
33 stringBuilder.Append(' ');
34 for (int i = 0; i < _innerExceptions.Length; i++)
35 {
36 stringBuilder.Append('(');
38 stringBuilder.Append(") ");
39 }
40 stringBuilder.Length--;
42 }
43 }
44
45 internal int InnerExceptionCount => _innerExceptions.Length;
46
48
50 : this(SR.AggregateException_ctor_DefaultMessage)
51 {
52 }
53
54 public AggregateException(string? message)
55 : base(message)
56 {
58 }
59
61 : base(message, innerException)
62 {
63 if (innerException == null)
64 {
65 throw new ArgumentNullException("innerException");
66 }
68 }
69
71 : this(SR.AggregateException_ctor_DefaultMessage, innerExceptions)
72 {
73 }
74
76 : this(SR.AggregateException_ctor_DefaultMessage, innerExceptions)
77 {
78 }
79
84
87 {
88 }
89
91 : base(message, (innerExceptions != null && innerExceptions.Length != 0) ? innerExceptions[0] : null)
92 {
93 if (innerExceptions == null)
94 {
95 throw new ArgumentNullException("innerExceptions");
96 }
98 for (int i = 0; i < _innerExceptions.Length; i++)
99 {
101 if (innerExceptions[i] == null)
102 {
104 }
105 }
106 }
107
109 : this(SR.AggregateException_ctor_DefaultMessage, innerExceptionInfos)
110 {
111 }
112
114 : base(message, (innerExceptionInfos.Count != 0) ? innerExceptionInfos[0].SourceException : null)
115 {
117 for (int i = 0; i < _innerExceptions.Length; i++)
118 {
119 _innerExceptions[i] = innerExceptionInfos[i].SourceException;
120 }
121 }
122
124 : base(info, context)
125 {
126 if (!(info.GetValue("InnerExceptions", typeof(Exception[])) is Exception[] innerExceptions))
127 {
129 }
131 }
132
134 {
135 base.GetObjectData(info, context);
136 info.AddValue("InnerExceptions", _innerExceptions, typeof(Exception[]));
137 }
138
139 public override Exception GetBaseException()
140 {
141 Exception ex = this;
142 AggregateException ex2 = this;
143 while (ex2 != null && ex2.InnerExceptions.Count == 1)
144 {
145 ex = ex.InnerException;
147 }
148 return ex;
149 }
150
151 public void Handle(Func<Exception, bool> predicate)
152 {
153 if (predicate == null)
154 {
155 throw new ArgumentNullException("predicate");
156 }
157 List<Exception> list = null;
158 for (int i = 0; i < _innerExceptions.Length; i++)
159 {
160 if (!predicate(_innerExceptions[i]))
161 {
162 if (list == null)
163 {
164 list = new List<Exception>();
165 }
166 list.Add(_innerExceptions[i]);
167 }
168 }
169 if (list != null)
170 {
171 throw new AggregateException(Message, list.ToArray(), cloneExceptions: false);
172 }
173 }
174
176 {
179 int num = 0;
180 while (list2.Count > num)
181 {
182 ReadOnlyCollection<Exception> innerExceptions = list2[num++].InnerExceptions;
183 for (int i = 0; i < innerExceptions.Count; i++)
184 {
186 if (ex != null)
187 {
189 {
190 list2.Add(item);
191 }
192 else
193 {
194 list.Add(ex);
195 }
196 }
197 }
198 }
199 return new AggregateException((GetType() == typeof(AggregateException)) ? base.Message : Message, list.ToArray(), cloneExceptions: false);
200 }
201
202 public override string ToString()
203 {
205 stringBuilder.Append(base.ToString());
206 for (int i = 0; i < _innerExceptions.Length; i++)
207 {
208 if (_innerExceptions[i] != base.InnerException)
209 {
210 stringBuilder.Append("\r\n ---> ");
213 stringBuilder.Append("<---");
214 stringBuilder.AppendLine();
215 }
216 }
217 return stringBuilder.ToString();
218 }
219}
ReadOnlyCollection< Exception > InnerExceptions
AggregateException Flatten()
AggregateException(string message, Exception[] innerExceptions, bool cloneExceptions)
ReadOnlyCollection< Exception > _rocView
override Exception GetBaseException()
AggregateException(SerializationInfo info, StreamingContext context)
readonly Exception[] _innerExceptions
override void GetObjectData(SerializationInfo info, StreamingContext context)
AggregateException(string? message, params Exception[] innerExceptions)
AggregateException(List< ExceptionDispatchInfo > innerExceptionInfos)
void Handle(Func< Exception, bool > predicate)
AggregateException(string? message, IEnumerable< Exception > innerExceptions)
AggregateException(string message, List< ExceptionDispatchInfo > innerExceptionInfos)
AggregateException(string? message)
AggregateException(string? message, Exception innerException)
AggregateException(IEnumerable< Exception > innerExceptions)
AggregateException(params Exception[] innerExceptions)
virtual void GetObjectData(SerializationInfo info, StreamingContext context)
void Add(TKey key, TValue value)
new Type GetType()
Definition Exception.cs:437
static CultureInfo InvariantCulture
static string AggregateException_DeserializationFailure
Definition SR.cs:46
static string AggregateException_ctor_InnerExceptionNull
Definition SR.cs:44
static string AggregateException_InnerException
Definition SR.cs:48
Definition SR.cs:7
static string GetStringAndRelease(StringBuilder sb)
static StringBuilder Acquire(int capacity=16)