add some error handling

master
Christopher 2020-07-01 18:38:05 +02:00
parent affd6cbeb3
commit 8295c88818
1 changed files with 30 additions and 15 deletions

View File

@ -257,22 +257,37 @@ namespace OpenSim.Modules.EMail
public Email GetNextEmail(UUID objectID, string sender, string subject) public Email GetNextEmail(UUID objectID, string sender, string subject)
{ {
SceneObjectPart sceneObject = m_scene.GetSceneObjectPart(objectID); SceneObjectPart sceneObject = m_scene.GetSceneObjectPart(objectID);
m_log.Info("[" + Name + "] GetNextEmail: " + sceneObject.Name + " (" + sceneObject.UUID + ")");
List<InternalMail> messages = m_messages.FindAll(X => X.ID == objectID); if(sceneObject != null)
if (messages.Count == 0) {
List<InternalMail> messages = m_messages.FindAll(X => X.ID == objectID);
if (messages.Count == 0)
return null;
if(messages[0] != null)
{
Email lslMessage = new Email();
lslMessage.time = messages[0].Mail.Date.ToUnixTimeSeconds().ToString();
lslMessage.message = messages[0].Mail.TextBody.ToString();
lslMessage.sender = messages[0].Mail.Sender.GetAddress(true);
lslMessage.subject = messages[0].Mail.Subject;
lslMessage.numLeft = messages.Count - 1;
m_messages.Remove(messages[0]);
return lslMessage;
}
else
{
m_log.Error("[" + Name + "] Cant find caller objekt!");
return null;
}
}
else
{
m_log.Error("[" + Name + "] Cant find caller objekt!");
return null; return null;
}
Email lslMessage = new Email();
lslMessage.time = messages[0].Mail.Date.ToUnixTimeSeconds().ToString();
lslMessage.message = messages[0].Mail.Body.ToString();
lslMessage.sender = messages[0].Mail.Sender.GetAddress(true);
lslMessage.subject = messages[0].Mail.Subject;
lslMessage.numLeft = messages.Count - 1;
m_messages.Remove(messages[0]);
return lslMessage;
} }
public bool isUUID(string thing) public bool isUUID(string thing)