mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
fix(api): don't 500 on invalid PATCH body
This commit is contained in:
parent
a20f0916ac
commit
97c14b20b0
3 changed files with 21 additions and 5 deletions
|
|
@ -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 {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue