Skip to content

Commit 5136f5a

Browse files
committed
better exception handling
1 parent 4cb8e18 commit 5136f5a

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project>
33
<PropertyGroup>
44
<NoWarn>CS1591;NU5104;CS1573;CS9107;NU1608;NU1109</NoWarn>
5-
<Version>31.0.1</Version>
5+
<Version>31.0.2</Version>
66
<LangVersion>preview</LangVersion>
77
<AssemblyVersion>1.0.0</AssemblyVersion>
88
<PackageTags>EntityFrameworkCore, EntityFramework, GraphQL</PackageTags>

src/GraphQL.EntityFramework/Where/ExpressionBuilder.cs

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,28 +75,35 @@ public static Expression<Func<T, bool>> BuildPredicate(string path, Comparison c
7575

7676
static Expression MakePredicateBody(string path, Comparison comparison, string?[]? values, bool negate)
7777
{
78-
Expression expressionBody;
79-
80-
// If path includes list property access
81-
if (HasListPropertyInPath(path))
82-
{
83-
// Handle a list path
84-
expressionBody = ProcessList(path, comparison, values!);
85-
}
86-
// Otherwise linear property access
87-
else
78+
try
8879
{
89-
// Just get expression
90-
expressionBody = GetExpression(path, comparison, values);
91-
}
80+
Expression expressionBody;
81+
82+
// If path includes list property access
83+
if (HasListPropertyInPath(path))
84+
{
85+
// Handle a list path
86+
expressionBody = ProcessList(path, comparison, values!);
87+
}
88+
// Otherwise linear property access
89+
else
90+
{
91+
// Just get expression
92+
expressionBody = GetExpression(path, comparison, values);
93+
}
9294

93-
// If the expression should be negated
94-
if (negate)
95+
// If the expression should be negated
96+
if (negate)
97+
{
98+
expressionBody = NegateExpression(expressionBody);
99+
}
100+
101+
return expressionBody;
102+
}
103+
catch (Exception exception)
95104
{
96-
expressionBody = NegateExpression(expressionBody);
105+
throw new ($"Failed to build expression. Path: {path}, Comparison: {comparison}, Negate: {negate}, ", exception);
97106
}
98-
99-
return expressionBody;
100107
}
101108

102109
static Expression ProcessList(string path, Comparison comparison, string?[]? values)

0 commit comments

Comments
 (0)