Merge branch 'catcherwong-fix-1045' into develop

This commit is contained in:
TomPallister 2020-01-19 17:20:53 +00:00
commit 81c81b5a48
2 changed files with 13 additions and 2 deletions

View File

@ -1,6 +1,6 @@
namespace Ocelot.Requester namespace Ocelot.Requester
{ {
using Errors; using Ocelot.Errors;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -23,7 +23,7 @@ namespace Ocelot.Requester
return _mappers[type](exception); return _mappers[type](exception);
} }
if (type == typeof(OperationCanceledException)) if (type == typeof(OperationCanceledException) || type.IsSubclassOf(typeof(OperationCanceledException)))
{ {
return new RequestCanceledError(exception.Message); return new RequestCanceledError(exception.Message);
} }

View File

@ -38,6 +38,14 @@
error.ShouldBeOfType<RequestCanceledError>(); error.ShouldBeOfType<RequestCanceledError>();
} }
[Fact]
public void should_return_request_canceled_for_subtype()
{
var error = _mapper.Map(new SomeException());
error.ShouldBeOfType<RequestCanceledError>();
}
[Fact] [Fact]
public void should_return_error_from_mapper() public void should_return_error_from_mapper()
{ {
@ -56,5 +64,8 @@
error.ShouldBeOfType<AnyError>(); error.ShouldBeOfType<AnyError>();
} }
private class SomeException : OperationCanceledException
{ }
} }
} }