mirror of
https://github.com/Biarity/Sieve.git
synced 2024-11-22 13:32:33 +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 bool CaseSensitive { get; set; } = false;
|
||||||
|
|
||||||
public int DefaultPageSize { get; set; } = 0;
|
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
|
catch (ArgumentException) // name matched with custom method for a differnt type
|
||||||
{
|
{
|
||||||
var expected = typeof(IQueryable<TEntity>);
|
if (_options.Value.ThrowExceptions)
|
||||||
var actual = customMethod.ReturnType;
|
{
|
||||||
throw new SieveIncompatibleMethodException(name, expected, actual,
|
var expected = typeof(IQueryable<TEntity>);
|
||||||
$"{name} failed. Expected a custom method for type {expected} but only found for type {actual}");
|
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,
|
throw new SieveMethodNotFoundException(name,
|
||||||
$"{name} not found.");
|
$"{name} not found.");
|
||||||
|
@ -20,7 +20,10 @@ namespace SieveUnitTests
|
|||||||
|
|
||||||
public SieveOptionsAccessor()
|
public SieveOptionsAccessor()
|
||||||
{
|
{
|
||||||
_value = new SieveOptions();
|
_value = new SieveOptions()
|
||||||
|
{
|
||||||
|
ThrowExceptions = true
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user