Kahbazi / MediatR.AspNetCore.Endpoints

MIT License
111 stars 12 forks source link

Can't handle Json deserialization exceptions #13

Closed cluka closed 2 years ago

cluka commented 2 years ago

As I see in the code, the deserialization exceptions (JsonException..) is swallowed. There is no Log entry written and the exception is not re-thrown. So When the exception happens, we only get Status Code 400 but not error why.

Kahbazi commented 2 years ago

Hi @cluka There's now an OnDeserializeError options, which lets you control what happens when an exception occurs during deserialization.

https://github.com/Kahbazi/MediatR.AspNetCore.Endpoints/blob/4f5d5fec2d636d4d4b1696d7de7dc68657562828/src/MediatR.AspNetCore.Endpoints/EndpointRouteBuilderExtensions.cs#L55-L66

https://github.com/Kahbazi/MediatR.AspNetCore.Endpoints/blob/4f5d5fec2d636d4d4b1696d7de7dc68657562828/src/MediatR.AspNetCore.Endpoints/MediatorEndpointOptions.cs#L12-L16

Let me know if this works for you and I will create a release.

cluka commented 2 years ago

Ok, this i very clean and it works for me.