Handle deserialization error
All checks were successful
Build, Push and Run Container / build (push) Successful in 25s

This commit is contained in:
2025-08-12 21:52:56 +02:00
parent a6f36c9ef7
commit 519d840b19

View File

@@ -63,13 +63,20 @@ public class TeslaAuthenticatorService
string json = await response.Content.ReadAsStringAsync(); string json = await response.Content.ReadAsStringAsync();
// Deserialize // Deserialize
Token? result = JsonSerializer.Deserialize<Token>(json); try
{
Token? result = JsonSerializer.Deserialize<Token>(json);
if (result is null) if (result is null)
throw new FormatException($"Could not deserialize token response: {json}"); throw new FormatException("Response could not be deserialized (null).");
// Return the token response // Return the token response
return result; return result;
}
catch (Exception e)
{
throw new AggregateException($"Could not deserialize token response: {json}", e);
}
} }
/// Retrieves a cached partner authentication token or acquires a new one if not available. /// Retrieves a cached partner authentication token or acquires a new one if not available.