mirror of
				https://github.com/Biarity/Sieve.git
				synced 2025-11-04 02:39:00 +01: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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -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
 | 
			
		||||
            };
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user