Skip to content

Commit

Permalink
Add try/catch block and some other sanity checking to CheckCargoForIt…
Browse files Browse the repository at this point in the history
…em()
  • Loading branch information
ISeeDEDPpl committed Apr 23, 2013
1 parent c81b136 commit 3653f05
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions Questor.Modules/Caching/Cache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2593,9 +2593,28 @@ private Func<EntityCache, int> OrderByLowestHealth()

public DirectItem CheckCargoForItem(int typeIdToFind, int quantityToFind)
{
DirectContainer cargo = Cache.Instance.DirectEve.GetShipsCargo();
DirectItem item = cargo.Items.FirstOrDefault(i => i.TypeId == typeIdToFind && i.Quantity >= quantityToFind);
return item;
try
{
if (Cache.Instance.DirectEve.GetShipsCargo() != null)
{
DirectContainer cargo = Cache.Instance.DirectEve.GetShipsCargo();
if (cargo.Items.Any())
{
DirectItem item = cargo.Items.FirstOrDefault(i => i.TypeId == typeIdToFind && i.Quantity >= quantityToFind);
return item;
}

return null; // no items found
}

return null;
}
catch (Exception exception)
{
Logging.Log("Cache.CheckCargoForItem", "Exception [" + exception + "]", Logging.Debug);
}

return null;
}

public bool CheckifRouteIsAllHighSec()
Expand Down

0 comments on commit 3653f05

Please sign in to comment.