diff --git a/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs b/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs
index c270f19..d5faa52 100644
--- a/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs
+++ b/ElectricLocomotive/Generics/LocomotivesGenericStorage.cs
@@ -158,7 +158,7 @@ namespace ProjectElectricLocomotive.Generics
using (StreamReader sr = new(filename))
{
string line;
- if (!((line = sr.ReadLine() != null) && line.StartsWith("LocomotiveStorage")))
+ if (!(((line = sr.ReadLine()) != null) && line.StartsWith("LocomotiveStorage")))
{
//если нет такой записи, то это не те данные
throw new ArgumentException("Неверный формат данных");
diff --git a/ElectricLocomotive/Generics/SetGeneric.cs b/ElectricLocomotive/Generics/SetGeneric.cs
index 6cb07b4..fbaf54f 100644
--- a/ElectricLocomotive/Generics/SetGeneric.cs
+++ b/ElectricLocomotive/Generics/SetGeneric.cs
@@ -71,11 +71,7 @@ namespace ProjectElectricLocomotive.Generics
///
public bool Remove(int position)
{
- if (position >= Count || position < 0)
- {
- return false;
- }
- if (_places[position] == null)
+ if (position >= Count || position < 0 || _places[position] == null)
{
throw new LocomotiveNotFoundException(position);
}
@@ -94,7 +90,7 @@ namespace ProjectElectricLocomotive.Generics
{
if (position >= Count || position < 0)
{
- return null;
+ throw new LocomotiveNotFoundException(position);
}
return _places[position];
}
diff --git a/ElectricLocomotive/LogicFormLocomotiveCollection.cs b/ElectricLocomotive/LogicFormLocomotiveCollection.cs
index 75ad021..ba3cb51 100644
--- a/ElectricLocomotive/LogicFormLocomotiveCollection.cs
+++ b/ElectricLocomotive/LogicFormLocomotiveCollection.cs
@@ -145,7 +145,7 @@ namespace ProjectElectricLocomotive
catch (StorageOverflowException ex)
{
MessageBox.Show(ex.Message);
- _logger.LogError(ex.ToString());
+ _logger.LogWarning(ex.ToString());
}
}
@@ -197,7 +197,7 @@ namespace ProjectElectricLocomotive
catch (LocomotiveNotFoundException ex)
{
MessageBox.Show(ex.Message);
- _logger.LogError(ex.ToString());
+ _logger.LogWarning(ex.ToString());
}
}
///
@@ -242,7 +242,7 @@ namespace ProjectElectricLocomotive
MessageBox.Show($"Не сохранилось: {ex.Message}",
"Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
_logger.LogInformation($"Не удалось сохранить в {saveFileDialog.FileName}: {ex.Message}");
- _logger.LogDebug(ex.ToString());
+ _logger.LogWarning(ex.ToString());
}
}
}
@@ -267,7 +267,7 @@ namespace ProjectElectricLocomotive
MessageBox.Show($"Не загрузилось: {ex.Message}",
"Результат", MessageBoxButtons.OK, MessageBoxIcon.Error);
_logger.LogInformation($"Не удалось загрузить из {openFileDialog.FileName}: {ex.Message}");
- _logger.LogDebug(ex.ToString());
+ _logger.LogWarning(ex.ToString());
}
}
}