-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deserializer throws exception when request body is empty. #16
Comments
Hello, in theory, Thoth.Json.Net should capture all the errors coming from Newtonsoft and map them into Can you please check what is the type of exception you are having? |
Using
|
The code you linked looks like it is from the string decoder and is wrapped in a try catch, but the call in Thoth.Json.Giraffe/src/ThothSerializer.fs Lines 56 to 68 in 4a18b7e
|
Hum, you are right it is using I guess we are using We should definitely port the try-catch from |
I forked it to take a look. Did you know the solution file (.sln) is missing? |
@BennieCopeland I just released a new version 4.3.0 with your changes in it.
I don't remember if Visual Studio requires it but Ionide, Rider, dotnet cli can work without it. As you can open a folder instead of a solution. I find sln files not really useful in general because it hides files from you or you have to add all your files to it. Where the file system already does that (kind of). Also, I am not really a .NET user more of a Fable user where sln are not needed either so I can be wrong. |
When using the ThothSerializer in Giraffe, attempting to deserialize an empty request body generates an exception from Newtonsoft.Json with
Error reading JToken from JsonReader
. The default Giraffe serializer (Utf8Json) returns null for the same case.This happens whether I use
ctx.BindJsonAsync
,Controller.getJson
, orThothSerializer.ReadBody
. For ReadBody, I would prefer this to just be an Error allowing me to return a 403 to the client.The text was updated successfully, but these errors were encountered: