mirror of
https://github.com/Biarity/Sieve.git
synced 2024-11-22 05:22:57 +01:00
Handle all possible exceptions using SieveExceptions (#11)
This commit is contained in:
parent
6d3fedf9f5
commit
67606e281b
@ -5,6 +5,13 @@ using System.Text;
|
||||
namespace Sieve.Exceptions
|
||||
{
|
||||
public class SieveException : Exception
|
||||
{
|
||||
public SieveException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public SieveException(string message, Exception innerException) : base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,6 +97,8 @@ namespace Sieve.Services
|
||||
ISieveModel<IFilterTerm, ISortTerm> model,
|
||||
IQueryable<TEntity> result,
|
||||
object[] dataForCustomMethods = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (model?.FiltersParsed == null)
|
||||
return result;
|
||||
@ -183,6 +185,13 @@ namespace Sieve.Services
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ex is SieveException)
|
||||
throw;
|
||||
throw new SieveException(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Apply sorting parameters found in `model` to `source`
|
||||
@ -196,6 +205,8 @@ namespace Sieve.Services
|
||||
ISieveModel<IFilterTerm, ISortTerm> model,
|
||||
IQueryable<TEntity> result,
|
||||
object[] dataForCustomMethods = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (model?.SortsParsed == null)
|
||||
return result;
|
||||
@ -224,6 +235,13 @@ namespace Sieve.Services
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ex is SieveException)
|
||||
throw;
|
||||
throw new SieveException(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Apply pagination parameters found in `model` to `source`
|
||||
@ -236,6 +254,8 @@ namespace Sieve.Services
|
||||
public IQueryable<TEntity> ApplyPagination<TEntity>(
|
||||
ISieveModel<IFilterTerm, ISortTerm> model,
|
||||
IQueryable<TEntity> result)
|
||||
{
|
||||
try
|
||||
{
|
||||
var page = model?.Page ?? 1;
|
||||
var pageSize = model?.PageSize ?? _options.Value.DefaultPageSize;
|
||||
@ -248,6 +268,13 @@ namespace Sieve.Services
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ex is SieveException)
|
||||
throw;
|
||||
throw new SieveException(ex.Message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected virtual SievePropertyMapper MapProperties(SievePropertyMapper mapper)
|
||||
|
Loading…
Reference in New Issue
Block a user