[Greenfield] if some json property are invalid, throw nice error instead of an exception (fix #2795)

This commit is contained in:
nicolas.dorier
2022-01-10 22:10:04 +09:00
parent e164b1f169
commit 8bea3dd21e
4 changed files with 12 additions and 2 deletions

View File

@@ -14,7 +14,7 @@ namespace BTCPayServer.Filters
{
if (context.Exception is NBitcoin.JsonConverters.JsonObjectException jsonObject)
{
context.Result = new ObjectResult(new GreenfieldValidationError(jsonObject.Path, jsonObject.Message)) { StatusCode = 400 };
context.Result = new ObjectResult(new[] { new GreenfieldValidationError(jsonObject.Path, jsonObject.Message) }) { StatusCode = 422 };
context.ExceptionHandled = true;
}
}