Improve error handling for problem details deserialization

Explicitly catch JsonException and NotSupportedException when reading problem details from HTTP responses. Add comments to clarify that these errors are ignored since problem details are optional, making error handling more precise and avoiding unintended exception swallowing.
This commit is contained in:
OlgunR
2026-05-11 14:24:46 +02:00
parent 8a22217866
commit 1c00449186

View File

@@ -1,4 +1,5 @@
using System.Net;
using System.Text.Json;
namespace DbFirst.BlazorWebApp.Services;
@@ -25,7 +26,14 @@ internal static class ApiClientHelper
problemDetail = problem.Detail ?? problem.Type;
}
}
catch { }
catch (JsonException)
{
// Ignoriere Fehler beim Lesen der Problem-Details, da sie optional sind
}
catch (NotSupportedException)
{
// Ignoriere Fehler beim Lesen der Problem-Details, da sie optional sind
}
var status = response.StatusCode;
var reason = response.ReasonPhrase;