Failing gracefully if unable to deserialize

Signed-off-by: Tobias Lønnerød Madsen <m@dsen.tv>
This commit is contained in:
Tobias Lønnerød Madsen 2019-07-05 15:01:43 +02:00
parent 0c4913724e
commit 6cec7411a3
No known key found for this signature in database
GPG Key ID: E51953EA8372F2AC
1 changed files with 9 additions and 3 deletions

View File

@ -35,9 +35,15 @@ namespace CloudNative.CloudEvents
var request = context.HttpContext.Request;
var cloudEvent = request.ToCloudEvent(new JsonEventFormatter());
return InputFormatterResult.SuccessAsync(cloudEvent);
try
{
var cloudEvent = request.ToCloudEvent();
return InputFormatterResult.SuccessAsync(cloudEvent);
}
catch (Exception)
{
return InputFormatterResult.FailureAsync();
}
}
protected override bool CanReadType(Type type)