mirror of
https://github.com/Biarity/Sieve.git
synced 2025-07-28 05:03:22 +02:00
Made excepton handling optional, off by default
This commit is contained in:
@@ -10,5 +10,7 @@ namespace Sieve.Models
|
||||
public bool CaseSensitive { get; set; } = false;
|
||||
|
||||
public int DefaultPageSize { get; set; } = 0;
|
||||
|
||||
public bool ThrowExceptions { get; set; } = false;
|
||||
}
|
||||
}
|
@@ -309,13 +309,16 @@ namespace Sieve.Services
|
||||
}
|
||||
catch (ArgumentException) // name matched with custom method for a differnt type
|
||||
{
|
||||
var expected = typeof(IQueryable<TEntity>);
|
||||
var actual = customMethod.ReturnType;
|
||||
throw new SieveIncompatibleMethodException(name, expected, actual,
|
||||
$"{name} failed. Expected a custom method for type {expected} but only found for type {actual}");
|
||||
if (_options.Value.ThrowExceptions)
|
||||
{
|
||||
var expected = typeof(IQueryable<TEntity>);
|
||||
var actual = customMethod.ReturnType;
|
||||
throw new SieveIncompatibleMethodException(name, expected, actual,
|
||||
$"{name} failed. Expected a custom method for type {expected} but only found for type {actual}");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (_options.Value.ThrowExceptions)
|
||||
{
|
||||
throw new SieveMethodNotFoundException(name,
|
||||
$"{name} not found.");
|
||||
|
Reference in New Issue
Block a user