add more error handling

master
Christopher 2020-07-10 17:28:23 +02:00
parent 49cb60bd8a
commit 90bf8b7487
1 changed files with 43 additions and 25 deletions

View File

@ -74,6 +74,8 @@ namespace OpenSim.Modules.Appearance2Avatar
SceneObjectPart _host = m_scene.GetSceneObjectPart(hostID);
ScenePresence sp = m_scene.GetScenePresence(UUID.Parse(targetAvatar));
if(_host != null)
{
if (sp != null)
{
TaskInventoryItem notecardItem = _host.Inventory.GetInventoryItems().Find(X => X.Name == notecard);
@ -87,18 +89,28 @@ namespace OpenSim.Modules.Appearance2Avatar
return;
}
m_log.Info("[" + Name + "] Info: Fetch asset data for notecard.");
AssetBase asset = m_scene.AssetService.Get(notecardItem.AssetID.ToString());
if (asset != null)
{
m_log.Info("[" + Name + "] Info: Convert notecard to string.");
String _appearanceNotecard = new ASCIIEncoding().GetString(asset.Data);
m_log.Info("[" + Name + "] Info: Deserialize notecard.");
OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(_appearanceNotecard);
AvatarAppearance appearance = new AvatarAppearance();
appearance.Unpack(appearanceOsd);
m_log.Info("[" + Name + "] Info: Overwrite appearance");
sp.Appearance = appearance;
sp.TriggerScenePresenceUpdated();
m_scene.ForEachClient(
client =>
{
sp.SendFullUpdateToClient(client);
});
}
else
{
@ -119,5 +131,11 @@ namespace OpenSim.Modules.Appearance2Avatar
throw new Exception("Target not found in region");
}
}
else
{
m_log.Error("[" + Name + "] ERROR: Cant find objekt inworld");
throw new Exception("Cant find objekt inworld");
}
}
}
}