fix(api): don't 500 on invalid PATCH body
This commit is contained in:
@@ -14,11 +14,23 @@ internal class QueryPatchWrapper
|
||||
return this;
|
||||
}
|
||||
|
||||
public Query ToQuery(Query q) => q.AsUpdate(_dict);
|
||||
public Query ToQuery(Query q)
|
||||
{
|
||||
try
|
||||
{
|
||||
return q.AsUpdate(_dict);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
throw new InvalidPatchException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static class SqlKataExtensions
|
||||
{
|
||||
internal static Query ApplyPatch(this Query query, Func<QueryPatchWrapper, QueryPatchWrapper> func)
|
||||
=> func(new QueryPatchWrapper()).ToQuery(query);
|
||||
}
|
||||
}
|
||||
|
||||
public class InvalidPatchException : Exception {}
|
Reference in New Issue
Block a user