mirror of
https://github.com/Biarity/Sieve.git
synced 2024-11-22 05:22:57 +01:00
Made excepton handling optional, off by default
This commit is contained in:
parent
ce5da2a573
commit
e83f647945
@ -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;
|
||||
}
|
||||
}
|
@ -308,6 +308,8 @@ namespace Sieve.Services
|
||||
}
|
||||
}
|
||||
catch (ArgumentException) // name matched with custom method for a differnt type
|
||||
{
|
||||
if (_options.Value.ThrowExceptions)
|
||||
{
|
||||
var expected = typeof(IQueryable<TEntity>);
|
||||
var actual = customMethod.ReturnType;
|
||||
@ -315,7 +317,8 @@ namespace Sieve.Services
|
||||
$"{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.");
|
||||
|
@ -20,7 +20,10 @@ namespace SieveUnitTests
|
||||
|
||||
public SieveOptionsAccessor()
|
||||
{
|
||||
_value = new SieveOptions();
|
||||
_value = new SieveOptions()
|
||||
{
|
||||
ThrowExceptions = true
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user