Handle deserialization error
All checks were successful
Build, Push and Run Container / build (push) Successful in 25s
All checks were successful
Build, Push and Run Container / build (push) Successful in 25s
This commit is contained in:
@@ -63,13 +63,20 @@ public class TeslaAuthenticatorService
|
||||
string json = await response.Content.ReadAsStringAsync();
|
||||
|
||||
// Deserialize
|
||||
Token? result = JsonSerializer.Deserialize<Token>(json);
|
||||
try
|
||||
{
|
||||
Token? result = JsonSerializer.Deserialize<Token>(json);
|
||||
|
||||
if (result is null)
|
||||
throw new FormatException($"Could not deserialize token response: {json}");
|
||||
|
||||
// Return the token response
|
||||
return result;
|
||||
if (result is null)
|
||||
throw new FormatException("Response could not be deserialized (null).");
|
||||
|
||||
// Return the token response
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user