From df0f1cb1385b9b5cb8b529b5ae9d492ebd018e84 Mon Sep 17 00:00:00 2001 From: Mark Crossley Date: Mon, 14 Oct 2024 19:59:24 +0100 Subject: [PATCH] Dump whole input file line to log file on error parsing it --- ImportWD.csproj | 2 +- WdExtraSensorsRecord.cs | 3 +++ WdIndoorRecord.cs | 3 +++ WdLgRecord.cs | 13 +++++++++++++ WdVantageExtraRecord.cs | 3 +++ WdVantageRecord.cs | 6 ++++++ 6 files changed, 29 insertions(+), 1 deletion(-) diff --git a/ImportWD.csproj b/ImportWD.csproj index 340f385..8f245ab 100644 --- a/ImportWD.csproj +++ b/ImportWD.csproj @@ -5,7 +5,7 @@ net8.0 enable enable - 0.0.4 + 0.0.5 ImportWD.Program Copyright © 2024-$([System.DateTime]::Now.ToString('yyyy')) Cumulus MX Cumulus MX diff --git a/WdExtraSensorsRecord.cs b/WdExtraSensorsRecord.cs index 212da1d..cc690f4 100644 --- a/WdExtraSensorsRecord.cs +++ b/WdExtraSensorsRecord.cs @@ -51,6 +51,7 @@ public WdExtraSensorsRecord(string entry) catch (Exception ex) { Program.LogMessage(" Error parsing date/time fields: " + ex.Message); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing date/time fields: " + ex.Message, ConsoleColor.Red); return; } @@ -72,6 +73,7 @@ public WdExtraSensorsRecord(string entry) else { Program.LogMessage($" Error parsing field {i} (temperature-{i - 4})"); + Program.LogMessage(" Error line: " + entry); Program.LogConsole($" Error parsing field {i} (temperature-{i - 4})", ConsoleColor.Red); } } @@ -91,6 +93,7 @@ public WdExtraSensorsRecord(string entry) else { Program.LogMessage($" Error parsing field {i} (humidity-{i - 5})"); + Program.LogMessage(" Error line: " + entry); Program.LogConsole($" Error parsing field {i} (humidity-{i - 5})", ConsoleColor.Red); } } diff --git a/WdIndoorRecord.cs b/WdIndoorRecord.cs index a2e2760..727ed08 100644 --- a/WdIndoorRecord.cs +++ b/WdIndoorRecord.cs @@ -32,6 +32,7 @@ public WdIndoorRecord(string entry) catch (Exception ex) { Program.LogMessage(" Error parsing date/time fields: " + ex.Message); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing date/time fields: " + ex.Message, ConsoleColor.Red); return; } @@ -44,6 +45,7 @@ public WdIndoorRecord(string entry) else { Program.LogMessage(" Error parsing field 6 (temperature})"); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing field 6 (temperature})", ConsoleColor.Red); } @@ -54,6 +56,7 @@ public WdIndoorRecord(string entry) else { Program.LogMessage(" Error parsing field 6 (humidity})"); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing field 6 (humidity})", ConsoleColor.Red); } } diff --git a/WdLgRecord.cs b/WdLgRecord.cs index e67f21e..c8658d7 100644 --- a/WdLgRecord.cs +++ b/WdLgRecord.cs @@ -48,6 +48,7 @@ public WdLgRecord(string entry) catch(Exception ex) { Program.LogMessage(" Error parsing date/time fields: " + ex.Message); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing date/time fields: " + ex.Message, ConsoleColor.Red); return; } @@ -60,6 +61,7 @@ public WdLgRecord(string entry) else { Program.LogMessage(" Error parsing field 6 (temperature)"); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing field 6 (temperature)", ConsoleColor.Red); } @@ -70,6 +72,7 @@ public WdLgRecord(string entry) else { Program.LogMessage(" Error parsing field 7 (humidity)"); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing field 7 (humidity)", ConsoleColor.Red); } @@ -80,6 +83,7 @@ public WdLgRecord(string entry) else { Program.LogMessage(" Error parsing field 8 (temperature)"); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing field 8 (temperature)", ConsoleColor.Red); } @@ -90,6 +94,7 @@ public WdLgRecord(string entry) else { Program.LogMessage(" Error parsing field 9 (pressure)"); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing field 9 (pressure)", ConsoleColor.Red); } @@ -106,6 +111,7 @@ public WdLgRecord(string entry) else { Program.LogMessage(" Error parsing field 10 (wind speed)"); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing field 10 (wind speed)", ConsoleColor.Red); } @@ -122,6 +128,7 @@ public WdLgRecord(string entry) else { Program.LogMessage(" Error parsing field 11 (wind gust)"); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing field 11 (wind gust)", ConsoleColor.Red); } @@ -132,6 +139,7 @@ public WdLgRecord(string entry) else { Program.LogMessage(" Error parsing field 12 (wind direction)"); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing field 12 (wind direction)", ConsoleColor.Red); } @@ -142,6 +150,7 @@ public WdLgRecord(string entry) else { Program.LogMessage(" Error parsing field 13 (rain 1 hr"); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing field 13 (rain 1 hr)", ConsoleColor.Red); } @@ -152,6 +161,7 @@ public WdLgRecord(string entry) else { Program.LogMessage(" Error parsing field 14 (rain day"); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing field 14 (rain day)", ConsoleColor.Red); } @@ -162,6 +172,7 @@ public WdLgRecord(string entry) else { Program.LogMessage(" Error parsing field 15 (rain month"); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing field 15 (rain month)", ConsoleColor.Red); } @@ -172,6 +183,7 @@ public WdLgRecord(string entry) else { Program.LogMessage(" Error parsing field 16 (rain year"); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing field 16 (rain year)", ConsoleColor.Red); } @@ -182,6 +194,7 @@ public WdLgRecord(string entry) else { Program.LogMessage(" Error parsing field 17 (heat index)"); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing field 17 (heat index)", ConsoleColor.Red); } } diff --git a/WdVantageExtraRecord.cs b/WdVantageExtraRecord.cs index 2fe9203..cfc9730 100644 --- a/WdVantageExtraRecord.cs +++ b/WdVantageExtraRecord.cs @@ -43,6 +43,7 @@ public WdVantageExtraRecord(string entry) catch (Exception ex) { Program.LogMessage(" Error parsing date/time fields: " + ex.Message); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing date/time fields: " + ex.Message, ConsoleColor.Red); return; } @@ -58,6 +59,7 @@ public WdVantageExtraRecord(string entry) else { Program.LogMessage($" Error parsing field {i + 5} (temperature-{i - 4})"); + Program.LogMessage(" Error line: " + entry); Program.LogConsole($" Error parsing field {i + 5} (temperature-{i - 4})", ConsoleColor.Red); } } @@ -71,6 +73,7 @@ public WdVantageExtraRecord(string entry) else { Program.LogMessage($" Error parsing field {i + 12} (humidity-{i - 11})"); + Program.LogMessage(" Error line: " + entry); Program.LogConsole($" Error parsing field {i + 12} (humidity-{i - 11})", ConsoleColor.Red); } } diff --git a/WdVantageRecord.cs b/WdVantageRecord.cs index e6ad8e2..62f979b 100644 --- a/WdVantageRecord.cs +++ b/WdVantageRecord.cs @@ -34,6 +34,7 @@ public WdVantageRecord(string entry) catch (Exception ex) { Program.LogMessage(" Error parsing date/time fields: " + ex.Message); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing date/time fields: " + ex.Message, ConsoleColor.Red); return; } @@ -46,6 +47,7 @@ public WdVantageRecord(string entry) else { Program.LogMessage(" Error parsing field 6 (solar rad)"); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing field 6 (solar rad)", ConsoleColor.Red); } @@ -56,6 +58,7 @@ public WdVantageRecord(string entry) else { Program.LogMessage(" Error parsing field 7 (UV-I)"); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing field 7 (UV-I)", ConsoleColor.Red); } @@ -66,6 +69,7 @@ public WdVantageRecord(string entry) else { Program.LogMessage(" Error parsing field 8 (ET)"); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing field 8 (ET)", ConsoleColor.Red); } @@ -77,6 +81,7 @@ public WdVantageRecord(string entry) else { Program.LogMessage(" Error parsing field 9 (soil moisture)"); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing field 9 (soil moisture)", ConsoleColor.Red); } @@ -87,6 +92,7 @@ public WdVantageRecord(string entry) else { Program.LogMessage(" Error parsing field 8 (soil temperature)"); + Program.LogMessage(" Error line: " + entry); Program.LogConsole(" Error parsing field 8 (soil temperature)", ConsoleColor.Red); } }