Skip to content

Commit

Permalink
Add Ignore overload that takes a predicate
Browse files Browse the repository at this point in the history
  • Loading branch information
khellang committed Sep 14, 2022
1 parent 2c41d08 commit 64f209d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/ProblemDetails/ProblemDetailsOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,18 @@ public ProblemDetailsOptions()
/// <typeparam name="TException">The exception type to ignore.</typeparam>
public void Ignore<TException>() where TException : Exception
{
Map<TException>(_ => null);
Map<TException>((_, _) => null);
}

/// <summary>
/// Configures the middleware to ignore exceptions of the specified exception type <typeparamref name="TException"/> that match the specified <paramref name="predicate"/>.
/// This will cause the exception to be rethrown to be handled upstream.
/// </summary>
/// <param name="predicate">The predicate to check whether the exception should be ignored or not.</param>
/// <typeparam name="TException">The exception type to ignore.</typeparam>
public void Ignore<TException>(Func<HttpContext, TException, bool> predicate) where TException : Exception
{
Map(predicate, (_, _) => null);
}

/// <summary>
Expand Down

0 comments on commit 64f209d

Please sign in to comment.