Skip to content

Commit

Permalink
Adding multiple types to handle ex
Browse files Browse the repository at this point in the history
  • Loading branch information
farajfarook committed Sep 19, 2018
1 parent 3e37799 commit 95651ea
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,6 +1,6 @@
env:
global:
- PACKAGE_VERSION="1.1.9"
- PACKAGE_VERSION="1.1.10"
- PACKAGE_ICON="https://www.enbiso.com/logo.svg"
- PACKAGE_PROJECT="https://nlib.enbiso.com"
- PACKAGE_REPO="https://github.com/enbiso/Enbiso.NLib"
Expand Down
2 changes: 1 addition & 1 deletion Enbiso.NLib.App.Extensions/GlobalExceptionFilter.cs
Expand Up @@ -25,7 +25,7 @@ public async Task OnExceptionAsync(ExceptionContext context)
context.Exception,
context.Exception.Message);

var handler = _handlers.FirstOrDefault(h => h.ValidType == context.Exception.GetType());
var handler = _handlers.FirstOrDefault(h => h.ValidTypes.Contains(context.Exception.GetType()));
if (handler != null)
{
var result = await handler.HandleException(context.Exception);
Expand Down
6 changes: 3 additions & 3 deletions Enbiso.NLib.GlobalExceptions/GlobalExceptionHandler.cs
Expand Up @@ -8,7 +8,7 @@ namespace Enbiso.NLib.Exceptions
/// </summary>
public interface IGlobalExceptionHandler
{
Type ValidType { get; }
Type[] ValidTypes { get; }

Task<GlobalExceptionResponse> HandleException(Exception exception);
}
Expand All @@ -17,10 +17,10 @@ public interface IGlobalExceptionHandler
/// Abstract Global exception handler
/// </summary>
/// <typeparam name="TException"></typeparam>
public abstract class AbstractGlobalExceptionHandler<TException> : IGlobalExceptionHandler
public abstract class GlobalExceptionHandler<TException> : IGlobalExceptionHandler
where TException : Exception
{
public Type ValidType => typeof(TException);
public Type[] ValidTypes => new [] { typeof(TException) };
protected abstract Task<GlobalExceptionResponse> Handle(TException ex);

public Task<GlobalExceptionResponse> HandleException(Exception exception)
Expand Down

0 comments on commit 95651ea

Please sign in to comment.