本文整理汇总了C#中System.AggregateException.Flatten方法的典型用法代码示例。如果您正苦于以下问题:C# AggregateException.Flatten方法的具体用法?C# AggregateException.Flatten怎么用?C# AggregateException.Flatten使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.AggregateException
的用法示例。
在下文中一共展示了AggregateException.Flatten方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: concatMessages
private static String concatMessages(AggregateException ae)
{
if (ae == null)
{
return "";
}
var flattened = ae.Flatten();
return String.Join("\n\n", from exc in flattened.InnerExceptions
select getExceptionMessages("", exc));
}
开发者ID:xebialabs-community,项目名称:xld-manifest-editor,代码行数:10,代码来源:DeployitServerConnectionException.cs
示例2: GetAggrateException
internal static string GetAggrateException(AggregateException ex)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine(string.Join(" ",
ex.Message,
ex.StackTrace));
foreach (var innerEx in ex.Flatten().InnerExceptions)
{
sb.AppendLine(GetExceptionString(ex));
}
return sb.ToString();
}
示例3: ParseExceptionMessage
private static void ParseExceptionMessage(StringBuilder sb, AggregateException aex)
{
if (aex != null)
{
ParseCommonExceptionMessage(sb, aex);
sb.AppendLine();
sb.AppendLine();
sb.AppendLine("InnerExceptions :");
sb.Append("===============================");
aex.Flatten().Handle((ex) =>
{
ParseAllExceptionMessage(sb, ex);
sb.AppendLine();
return true;
});
}
}
示例4: FinishRebuildAll
public void FinishRebuildAll(TaskStatus status, AggregateException exception)
{
_writeline($"Finished RebuildAll with status {status}");
if (exception != null)
{
var flattened = exception.Flatten();
foreach (var ex in flattened.InnerExceptions)
{
_writeline("");
_writeline("---------");
_writeline("Exception:");
_writeline("---------");
_writeline(ex.ToString());
_writeline("");
}
}
}
示例5: AddProblem
public NugetProblem AddProblem(AggregateException aggregate)
{
var message = "Fatal error";
Exception exception = aggregate;
if (aggregate != null)
{
exception = aggregate.Flatten();
message = exception.Message;
if (exception.InnerException != null)
{
exception = exception.InnerException;
message = exception.Message;
}
}
var problem = new NugetProblem(message, exception);
AddProblem(problem);
return problem;
}
示例6: Flatten
public static void Flatten()
{
Exception exceptionA = new Exception("A");
Exception exceptionB = new Exception("B");
Exception exceptionC = new Exception("C");
AggregateException aggExceptionBase = new AggregateException(exceptionA, exceptionB, exceptionC);
// Verify flattening one with another.
// > Flattening (no recursion)...
AggregateException flattened1 = aggExceptionBase.Flatten();
Exception[] expected1 = new Exception[] {
exceptionA, exceptionB, exceptionC
};
Assert.Equal(expected1, flattened1.InnerExceptions);
// Verify flattening one with another, accounting for recursion.
AggregateException aggExceptionRecurse = new AggregateException(aggExceptionBase, aggExceptionBase);
AggregateException flattened2 = aggExceptionRecurse.Flatten();
Exception[] expected2 = new Exception[] {
exceptionA, exceptionB, exceptionC, exceptionA, exceptionB, exceptionC,
};
Assert.Equal(expected2, flattened2.InnerExceptions);
}
示例7: FileErrored
private void FileErrored(ProcessingFile processingFile, AggregateException exception)
{
Logger.Error(string.Format("File processing failed: {0}", processingFile.OriginalFilePath), exception.Flatten());
this.processResultHandler.Handle(FileProcessResult.Error, processingFile);
}
示例8: FindException
static Exception FindException(AggregateException exception) {
foreach (var e in exception.Flatten().InnerExceptions) {
if (e is Win32Exception)
return e;
var ce = e as CompositionException;
if (ce != null) {
var found = FindException(ce);
if (found != null)
return found;
}
if (!(e is XamlException))
continue;
var inner = e.FindInnerException<Win32Exception>();
if (inner != null)
return inner;
}
return null;
}
示例9: PrintAggregateException
/// <summary>
/// Processes all exceptions inside an <see cref="AggregateException"/> and writes each inner exception to the console.
/// </summary>
/// <param name="aggregateException">The <see cref="AggregateException"/> to process.</param>
public static void PrintAggregateException(AggregateException aggregateException)
{
// Flatten the aggregate and iterate over its inner exceptions, printing each
foreach (Exception exception in aggregateException.Flatten().InnerExceptions)
{
Console.WriteLine(exception.ToString());
Console.WriteLine();
}
}
示例10: DumpException
private static void DumpException(AggregateException ex, StreamWriter sw, string header)
{
AggregateException flat = ex.Flatten();
if (header != null)
{
sw.WriteLine("Custom header message:");
sw.WriteLine(header);
sw.WriteLine("---");
}
sw.WriteLine("Aggregate Exception: " + ex.Message);
sw.WriteLine("---");
foreach (Exception eo in ex.InnerExceptions)
{
DumpException(eo, sw, null);
}
}
示例11: HandleException
/// <summary>
/// Exception handler for the connection class
/// </summary>
/// <param name="exception"></param>
public static void HandleException(AggregateException exception)
{
if (exception == null) return;
foreach (var ex in exception.Flatten().InnerExceptions)
{
Log(ex.StackTrace);
}
}