From 2011d1104cf48cb06d23e34878b124b4ac830422 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 19 Aug 2021 11:33:25 +0200 Subject: [PATCH] Update s evitare eccezioni in setRSV se key empty --- SteamWare.IO/memLayer.cs | 24 +++++++++++++++++++----- SteamWareLib/memLayer.cs | 24 +++++++++++++++++++----- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/SteamWare.IO/memLayer.cs b/SteamWare.IO/memLayer.cs index 77b9aeb..a66f979 100644 --- a/SteamWare.IO/memLayer.cs +++ b/SteamWare.IO/memLayer.cs @@ -2144,14 +2144,28 @@ namespace SteamWare.IO public bool setRSV(string chiave, string valore) { bool answ = false; - try + if (!string.IsNullOrEmpty(chiave)) { - cache.StringSet(chiave, valore); - answ = true; + if (!string.IsNullOrEmpty(valore)) + { + try + { + cache.StringSet(chiave, valore); + answ = true; + } + catch (Exception exc) + { + Logging.Instance.Error(string.Format("Eccezzione in setRSV:{0}{1}", Environment.NewLine, exc)); + } + } + else + { + Logging.Instance.Error("Errore: valore non valido (vuoto) in setRSV"); + } } - catch (Exception exc) + else { - Logging.Instance.Error(string.Format("Eccezzione in setRSV:{0}{1}", Environment.NewLine, exc)); + Logging.Instance.Error("Errore: chiave non valida (vuota) in setRSV"); } return answ; } diff --git a/SteamWareLib/memLayer.cs b/SteamWareLib/memLayer.cs index c1531a8..f9afd90 100644 --- a/SteamWareLib/memLayer.cs +++ b/SteamWareLib/memLayer.cs @@ -2161,14 +2161,28 @@ namespace SteamWare public bool setRSV(string chiave, string valore) { bool answ = false; - try + if (!string.IsNullOrEmpty(chiave)) { - cache.StringSet(chiave, valore); - answ = true; + if (!string.IsNullOrEmpty(valore)) + { + try + { + cache.StringSet(chiave, valore); + answ = true; + } + catch (Exception exc) + { + logger.lg.scriviLog($"Eccezzione in setRSV | chiave: {chiave} | valore: {valore}{Environment.NewLine}{exc}", tipoLog.EXCEPTION); + } + } + else + { + logger.lg.scriviLog("Errore: valore non valido (vuoto) in setRSV", tipoLog.ERROR); + } } - catch (Exception exc) + else { - logger.lg.scriviLog(string.Format($"Errore in setRSV | chiave: {chiave} | valore: {valore}{Environment.NewLine}{exc}"), tipoLog.EXCEPTION); + logger.lg.scriviLog("Errore: chiave non valida (vuota) in setRSV", tipoLog.ERROR); } return answ; }