From ae2454821628d847b0add20a4c593162baafde5b Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 29 Jun 2010 18:54:31 +0100 Subject: [PATCH] stop exceptions in setting and getting state from propogating since they aren't fatal to operations this will hopefully stop "save oar" from failing if a script asset is corrupt --- .../Scenes/SceneObjectPartInventory.cs | 39 +++++++++++++++---- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index d175695833..5ab7d20ba6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -217,7 +217,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (IScriptModule e in engines) { if (e != null) - { + { ArrayList errors = e.GetScriptErrors(itemID); foreach (Object line in errors) ret.Add(line); @@ -359,14 +359,26 @@ namespace OpenSim.Region.Framework.Scenes m_part.ParentGroup.m_savedScriptState[oldID] = newDoc.OuterXml; } + foreach (IScriptModule e in engines) { if (e != null) { - if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[oldID])) - break; + // Stop an exception in setting saved state from propogating since this is not fatal. + try + { + if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[oldID])) + break; + } + catch (Exception ex) + { + m_log.WarnFormat( + "[PRIM INVENTORY]: Could not set script state for old key {0}, new key {1} in prim {2} {3}. Exception {4}{5}", + oldID, newID, m_part.Name, m_part.UUID, ex.Message, ex.StackTrace); + } } } + m_part.ParentGroup.m_savedScriptState.Remove(oldID); } } @@ -1028,12 +1040,23 @@ namespace OpenSim.Region.Framework.Scenes { if (e != null) { - string n = e.GetXMLState(item.ItemID); - if (n != String.Empty) + // Stop any exception from the script engine from propogating since setting state + // isn't essential. + try { - if (!ret.ContainsKey(item.ItemID)) - ret[item.ItemID] = n; - break; + string n = e.GetXMLState(item.ItemID); + if (n != String.Empty) + { + if (!ret.ContainsKey(item.ItemID)) + ret[item.ItemID] = n; + break; + } + } + catch (Exception ex) + { + m_log.WarnFormat( + "[PRIM INVENTORY]: Could not retrieve script state for item {0} {1} in prim {2} {3}. Exception {4}{5}", + item.Name, item.ItemID, m_part.Name, m_part.UUID, ex.Message, ex.StackTrace); } } }