diff --git a/Source/ProofOfConcept/Services/TeslaAuthenticatorService.cs b/Source/ProofOfConcept/Services/TeslaAuthenticatorService.cs index ed8b855..5038589 100644 --- a/Source/ProofOfConcept/Services/TeslaAuthenticatorService.cs +++ b/Source/ProofOfConcept/Services/TeslaAuthenticatorService.cs @@ -63,13 +63,20 @@ public class TeslaAuthenticatorService string json = await response.Content.ReadAsStringAsync(); // Deserialize - Token? result = JsonSerializer.Deserialize(json); + try + { + Token? result = JsonSerializer.Deserialize(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.