Merge pull request #486 from Cysharp/hadashiA/inner-ex
Use innerException for `Task.AsUniTask`master
commit
b071eeadfb
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace NetCoreTests
|
||||
{
|
||||
public class TaskExtensionsTest
|
||||
{
|
||||
[Fact]
|
||||
public async Task PropagateException()
|
||||
{
|
||||
await Assert.ThrowsAsync<InvalidOperationException>(async () =>
|
||||
{
|
||||
await ThrowAsync().AsUniTask();
|
||||
});
|
||||
|
||||
await Assert.ThrowsAsync<InvalidOperationException>(async () =>
|
||||
{
|
||||
await ThrowOrValueAsync().AsUniTask();
|
||||
});
|
||||
}
|
||||
|
||||
async Task ThrowAsync()
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
async Task<int> ThrowOrValueAsync()
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ namespace Cysharp.Threading.Tasks
|
|||
p.TrySetCanceled();
|
||||
break;
|
||||
case TaskStatus.Faulted:
|
||||
p.TrySetException(x.Exception);
|
||||
p.TrySetException(x.Exception.InnerExceptions.Count == 1 ? x.Exception.InnerException : x.Exception);
|
||||
break;
|
||||
case TaskStatus.RanToCompletion:
|
||||
p.TrySetResult(x.Result);
|
||||
|
@ -58,7 +58,7 @@ namespace Cysharp.Threading.Tasks
|
|||
p.TrySetCanceled();
|
||||
break;
|
||||
case TaskStatus.Faulted:
|
||||
p.TrySetException(x.Exception);
|
||||
p.TrySetException(x.Exception.InnerExceptions.Count == 1 ? x.Exception.InnerException : x.Exception);
|
||||
break;
|
||||
case TaskStatus.RanToCompletion:
|
||||
p.TrySetResult();
|
||||
|
|
Loading…
Reference in New Issue