Some error handling to avoid errors in SEC
parent
2dbb32ff15
commit
9c8aeff27c
|
@ -72,21 +72,25 @@ namespace OpenSim.ApplicationPlugins.ScriptEngine
|
||||||
foreach (string c in ComponentList)
|
foreach (string c in ComponentList)
|
||||||
{
|
{
|
||||||
m_log.Info("[" + Name + "]: Loading: " + c);
|
m_log.Info("[" + Name + "]: Loading: " + c);
|
||||||
|
lock (Components)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (ComponentRegistry.providers.ContainsKey(c))
|
if (ComponentRegistry.providers.ContainsKey(c))
|
||||||
Components.Add(Activator.CreateInstance(ComponentRegistry.providers[c]) as ComponentBase);
|
Components.Add(Activator.CreateInstance(ComponentRegistry.providers[c]) as ComponentBase);
|
||||||
else
|
else
|
||||||
m_log.Error("[" + Name + "]: Component \"" + c + "\" not found, can not load");
|
m_log.Error("[" + Name + "]: Component \"" + c + "\" not found, can not load");
|
||||||
} catch (Exception ex)
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
m_log.Error("[" + Name + "]: Exception loading \"" + c + "\": " + ex.ToString());
|
m_log.Error("[" + Name + "]: Exception loading \"" + c + "\": " + ex.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Run Initialize on all our providers, hand over a reference of ourself.
|
// Run Initialize on all our providers, hand over a reference of ourself.
|
||||||
foreach (ComponentBase p in Components)
|
foreach (ComponentBase p in Components.ToArray())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -94,23 +98,32 @@ namespace OpenSim.ApplicationPlugins.ScriptEngine
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
m_log.Error("[" + Name + "]: Error initializing \"" + p.GetType().FullName + "\": " + ex.ToString());
|
lock (Components)
|
||||||
|
{
|
||||||
|
m_log.Error("[" + Name + "]: Error initializing \"" + p.GetType().FullName + "\": " +
|
||||||
|
ex.ToString());
|
||||||
|
if (Components.Contains(p))
|
||||||
Components.Remove(p);
|
Components.Remove(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// All modules has been initialized, call Start() on them.
|
// All modules has been initialized, call Start() on them.
|
||||||
foreach (ComponentBase p in Components)
|
foreach (ComponentBase p in Components.ToArray())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
p.Start();
|
p.Start();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
lock (Components)
|
||||||
{
|
{
|
||||||
m_log.Error("[" + Name + "]: Error starting \"" + p.GetType().FullName + "\": " + ex.ToString());
|
m_log.Error("[" + Name + "]: Error starting \"" + p.GetType().FullName + "\": " + ex.ToString());
|
||||||
|
if (Components.Contains(p))
|
||||||
Components.Remove(p);
|
Components.Remove(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +162,7 @@ namespace OpenSim.ApplicationPlugins.ScriptEngine
|
||||||
PreClose();
|
PreClose();
|
||||||
|
|
||||||
// Then Call Close() on all components
|
// Then Call Close() on all components
|
||||||
foreach (ComponentBase p in Components)
|
foreach (ComponentBase p in Components.ToArray())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,9 +45,18 @@ namespace OpenSim.ApplicationPlugins.ScriptEngine
|
||||||
{
|
{
|
||||||
// New region is being created
|
// New region is being created
|
||||||
// Create a new script engine
|
// Create a new script engine
|
||||||
scriptEngine = Activator.CreateInstance(ComponentRegistry.scriptEngines[tempScriptEngineName]) as RegionScriptEngineBase;
|
try
|
||||||
|
{
|
||||||
|
scriptEngine =
|
||||||
|
Activator.CreateInstance(ComponentRegistry.scriptEngines[tempScriptEngineName]) as
|
||||||
|
RegionScriptEngineBase;
|
||||||
scriptEngine.Initialize(scene, source);
|
scriptEngine.Initialize(scene, source);
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
scriptEngine.m_log.Error("[ScriptEngine]: Unable to load engine \"" + tempScriptEngineName + "\": " + ex.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void PostInitialise()
|
public void PostInitialise()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue