mirror of
				https://github.com/Biarity/Sieve.git
				synced 2025-11-04 02:39:00 +01:00 
			
		
		
		
	Cleaner exception handling
This commit is contained in:
		@@ -357,16 +357,13 @@ 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;
 | 
			
		||||
                        throw new SieveIncompatibleMethodException(name, expected, actual,
 | 
			
		||||
                            $"{name} failed. Expected a custom method for type {expected} but only found for type {actual}");
 | 
			
		||||
                    }
 | 
			
		||||
                    var expected = typeof(IQueryable<TEntity>);
 | 
			
		||||
                    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 if (_options.Value.ThrowExceptions)
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                throw new SieveMethodNotFoundException(name, 
 | 
			
		||||
                    $"{name} not found.");
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user