mirror of
https://github.com/Biarity/Sieve.git
synced 2024-11-22 13:32:33 +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
|
namespace Sieve.Exceptions
|
||||||
{
|
{
|
||||||
public class SieveException : Exception
|
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,
|
ISieveModel<IFilterTerm, ISortTerm> model,
|
||||||
IQueryable<TEntity> result,
|
IQueryable<TEntity> result,
|
||||||
object[] dataForCustomMethods = null)
|
object[] dataForCustomMethods = null)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (model?.FiltersParsed == null)
|
if (model?.FiltersParsed == null)
|
||||||
return result;
|
return result;
|
||||||
@ -183,6 +185,13 @@ namespace Sieve.Services
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
if (ex is SieveException)
|
||||||
|
throw;
|
||||||
|
throw new SieveException(ex.Message, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Apply sorting parameters found in `model` to `source`
|
/// Apply sorting parameters found in `model` to `source`
|
||||||
@ -196,6 +205,8 @@ namespace Sieve.Services
|
|||||||
ISieveModel<IFilterTerm, ISortTerm> model,
|
ISieveModel<IFilterTerm, ISortTerm> model,
|
||||||
IQueryable<TEntity> result,
|
IQueryable<TEntity> result,
|
||||||
object[] dataForCustomMethods = null)
|
object[] dataForCustomMethods = null)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (model?.SortsParsed == null)
|
if (model?.SortsParsed == null)
|
||||||
return result;
|
return result;
|
||||||
@ -224,6 +235,13 @@ namespace Sieve.Services
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
if (ex is SieveException)
|
||||||
|
throw;
|
||||||
|
throw new SieveException(ex.Message, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Apply pagination parameters found in `model` to `source`
|
/// Apply pagination parameters found in `model` to `source`
|
||||||
@ -236,6 +254,8 @@ namespace Sieve.Services
|
|||||||
public IQueryable<TEntity> ApplyPagination<TEntity>(
|
public IQueryable<TEntity> ApplyPagination<TEntity>(
|
||||||
ISieveModel<IFilterTerm, ISortTerm> model,
|
ISieveModel<IFilterTerm, ISortTerm> model,
|
||||||
IQueryable<TEntity> result)
|
IQueryable<TEntity> result)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var page = model?.Page ?? 1;
|
var page = model?.Page ?? 1;
|
||||||
var pageSize = model?.PageSize ?? _options.Value.DefaultPageSize;
|
var pageSize = model?.PageSize ?? _options.Value.DefaultPageSize;
|
||||||
@ -248,6 +268,13 @@ namespace Sieve.Services
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
if (ex is SieveException)
|
||||||
|
throw;
|
||||||
|
throw new SieveException(ex.Message, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected virtual SievePropertyMapper MapProperties(SievePropertyMapper mapper)
|
protected virtual SievePropertyMapper MapProperties(SievePropertyMapper mapper)
|
||||||
|
Loading…
Reference in New Issue
Block a user