parent
d8a95c731b
commit
3eae7cc393
|
|
@ -136,5 +136,23 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
|
||||||
Assert.Contains("Loader Exceptions:", content);
|
Assert.Contains("Loader Exceptions:", content);
|
||||||
Assert.Contains(expectedMessage, content);
|
Assert.Contains(expectedMessage, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async void AggregateException_FlattensInnerExceptions()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
var aggregateException = "AggregateException: One or more errors occurred.";
|
||||||
|
var nullReferenceException = "NullReferenceException: Foo cannot be null";
|
||||||
|
var indexOutOfRangeException = "IndexOutOfRangeException: Index is out of range";
|
||||||
|
|
||||||
|
// Act
|
||||||
|
var response = await Client.GetAsync("http://localhost/AggregateException");
|
||||||
|
var content = await response.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Contains(aggregateException, content);
|
||||||
|
Assert.Contains(nullReferenceException, content);
|
||||||
|
Assert.Contains(indexOutOfRangeException, content);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
namespace ErrorPageMiddlewareWebSite
|
||||||
|
{
|
||||||
|
public class AggregateExceptionController : Controller
|
||||||
|
{
|
||||||
|
[HttpGet("/AggregateException")]
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
var firstException = ThrowNullReferenceException();
|
||||||
|
var secondException = ThrowIndexOutOfRangeException();
|
||||||
|
Task.WaitAll(firstException, secondException);
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task ThrowNullReferenceException()
|
||||||
|
{
|
||||||
|
await Task.Delay(0);
|
||||||
|
throw new NullReferenceException("Foo cannot be null");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async Task ThrowIndexOutOfRangeException()
|
||||||
|
{
|
||||||
|
await Task.Delay(0);
|
||||||
|
throw new IndexOutOfRangeException("Index is out of range");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue