From d4c036e2884476a8b4666bd7ce60f96786f58493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20K=C3=BChnel?= Date: Mon, 12 Feb 2024 16:52:00 +0100 Subject: [PATCH] feat(FleetApiService): log response strings on non success status codes --- .../Server/Services/TeslaFleetApiService.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/TeslaSolarCharger/Server/Services/TeslaFleetApiService.cs b/TeslaSolarCharger/Server/Services/TeslaFleetApiService.cs index 897b5e9ef..50bbdca34 100644 --- a/TeslaSolarCharger/Server/Services/TeslaFleetApiService.cs +++ b/TeslaSolarCharger/Server/Services/TeslaFleetApiService.cs @@ -760,7 +760,7 @@ private async Task HandleNonSuccessTeslaApiStatusCodes(HttpStatusCode statusCode if (statusCode == HttpStatusCode.Unauthorized) { logger.LogError( - "Your token or refresh token is invalid. Very likely you have changed your Tesla password."); + "Your token or refresh token is invalid. Very likely you have changed your Tesla password. Response: {responseString}", responseString); teslaSolarChargerContext.TeslaTokens.Remove(token); teslaSolarChargerContext.TscConfigurations.Add(new TscConfiguration() { @@ -769,7 +769,7 @@ private async Task HandleNonSuccessTeslaApiStatusCodes(HttpStatusCode statusCode } else if (statusCode == HttpStatusCode.Forbidden) { - logger.LogError("You did not select all scopes, so TSC can't send commands to your car."); + logger.LogError("You did not select all scopes, so TSC can't send commands to your car. Response: {responseString}", responseString); teslaSolarChargerContext.TeslaTokens.Remove(token); teslaSolarChargerContext.TscConfigurations.Add(new TscConfiguration() { @@ -779,7 +779,7 @@ private async Task HandleNonSuccessTeslaApiStatusCodes(HttpStatusCode statusCode else if (statusCode == HttpStatusCode.InternalServerError && responseString.Contains("vehicle rejected request: your public key has not been paired with the vehicle")) { - logger.LogError("Vehicle {vin} is not paired with TSC. Add The public key to the vehicle", vin); + logger.LogError("Vehicle {vin} is not paired with TSC. Add The public key to the vehicle. Response: {responseString}", vin, responseString); var teslaMateCarId = teslamateContext.Cars.First(c => c.Vin == vin).Id; var car = teslaSolarChargerContext.Cars.First(c => c.TeslaMateCarId == teslaMateCarId); car.TeslaFleetApiState = TeslaCarFleetApiState.NotWorking; @@ -787,8 +787,8 @@ private async Task HandleNonSuccessTeslaApiStatusCodes(HttpStatusCode statusCode else { logger.LogWarning( - "Staus Code {statusCode} is currently not handled, look into https://developer.tesla.com/docs/fleet-api#response-codes to check status code information", - statusCode); + "Staus Code {statusCode} is currently not handled, look into https://developer.tesla.com/docs/fleet-api#response-codes to check status code information. Response: {responseString}", + statusCode, responseString); return; }