diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/CarNotFoundException.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/CarNotFoundException.cs deleted file mode 100644 index 19b8d4a..0000000 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/CarNotFoundException.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Runtime.Serialization; - - -namespace ProjectTractor.Exceptions -{ - [Serializable] - internal class CarNotFoundException : ApplicationException - { - public CarNotFoundException(int i) : base($"Не найден объект по позиции { i}") { } - public CarNotFoundException() : base() { } - public CarNotFoundException(string message) : base(message) { } - public CarNotFoundException(string message, Exception exception) : - base(message, exception) - { } - protected CarNotFoundException(SerializationInfo info, - StreamingContext contex) : base(info, contex) { } - } - -} diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/StorageOverflowException.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/StorageOverflowException.cs deleted file mode 100644 index 81d05e7..0000000 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/StorageOverflowException.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Runtime.Serialization; - - -namespace ProjectTractor.Exceptions -{ - [Serializable] - internal class StorageOverflowException : ApplicationException - { - public StorageOverflowException(int count) : base($"В наборе превышено допустимое количество: { count}") { } - public StorageOverflowException() : base() { } - public StorageOverflowException(string message) : base(message) { } - public StorageOverflowException(string message, Exception exception) - : base(message, exception) { } - protected StorageOverflowException(SerializationInfo info, - StreamingContext contex) : base(info, contex) { } - } - -} diff --git a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/TractorsGenericStorage.cs b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/TractorsGenericStorage.cs index d71695f..273c34d 100644 --- a/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/TractorsGenericStorage.cs +++ b/RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/TractorsGenericStorage.cs @@ -114,7 +114,7 @@ namespace ProjectTractor } if (data.Length == 0) { - return false; + throw new Exception("Невалидная операция, нет данных для сохранения"); } using (StreamWriter streamWriter = new(filename)) { @@ -139,11 +139,11 @@ namespace ProjectTractor string[] strings = str.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); if (strings == null || strings.Length == 0) { - return false; + throw new IOException("Нет данных для загрузки"); } if (!strings[0].StartsWith("TractorStorage")) { - return false; + throw new IOException("Неверный формат данных"); } _tractorStorages.Clear(); do @@ -163,7 +163,7 @@ namespace ProjectTractor { if (!(collection + tractor)) { - return false; + throw new ArgumentNullException("Ошибка добавления в коллекцию"); } } }