diff --git a/WarmlyShip/WarmlyShip/FormShipCollection.cs b/WarmlyShip/WarmlyShip/FormShipCollection.cs
index 29613ca..4e89f0f 100644
--- a/WarmlyShip/WarmlyShip/FormShipCollection.cs
+++ b/WarmlyShip/WarmlyShip/FormShipCollection.cs
@@ -145,16 +145,19 @@ namespace WarmlyShip
_logger.LogWarning("Добавление пустого объекта");
return;
}
- if (obj + drawingWarmlyShip)
+ try
{
- MessageBox.Show("Объект добавлен");
- pictureBoxCollection.Image = obj.ShowShips();
- _logger.LogInformation($"Объект {obj.GetType()} добавлен");
+ if (obj + drawingWarmlyShip)
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBoxCollection.Image = obj.ShowShips();
+ _logger.LogInformation($"Объект {obj.GetType()} добавлен");
+ }
}
- else
+ catch (StorageOverflowException ex)
{
- MessageBox.Show("Не удалось добавить объект");
- _logger.LogInformation($"Не удалось добавить объект");
+ MessageBox.Show(ex.Message);
+ _logger.LogWarning($"{ex.Message} в наборе {listBoxStorages.SelectedItem.ToString()}");
}
}
diff --git a/WarmlyShip/WarmlyShip/SetGeneric.cs b/WarmlyShip/WarmlyShip/SetGeneric.cs
index 0ac82af..39b0e72 100644
--- a/WarmlyShip/WarmlyShip/SetGeneric.cs
+++ b/WarmlyShip/WarmlyShip/SetGeneric.cs
@@ -39,12 +39,7 @@ namespace WarmlyShip.Generics
///
public bool Insert(T warmlyship)
{
- if (_places.Count == _maxCount)
- {
- return false;
- }
- Insert(warmlyship, 0);
- return true;
+ return Insert(warmlyship, 0);
}
///
/// Добавление объекта в набор на конкретную позицию
@@ -57,7 +52,7 @@ namespace WarmlyShip.Generics
if (position < 0 || position >= _maxCount)
throw new ShipNotFoundException(position);
- if (_places.Count >= _maxCount)
+ if (Count >= _maxCount)
throw new StorageOverflowException(_maxCount);
_places.Insert(0, warmlyship);
return true;