From baa9a24290cd1f669ff0f4b4ae6104dada36eb15 Mon Sep 17 00:00:00 2001 From: Kirill <117719052+KirillFirsof@users.noreply.github.com> Date: Mon, 25 Dec 2023 22:22:47 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BC=D0=B8=D1=821?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CarNotFoundException.cs | 24 ------------------- .../StorageOverflowException.cs | 23 ------------------ .../TractorsGenericStorage.cs | 8 +++---- 3 files changed, 4 insertions(+), 51 deletions(-) delete mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/CarNotFoundException.cs delete mode 100644 RPP_FirstLaba_Tractor/RPP_FirstLaba_Tractor/StorageOverflowException.cs 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("Ошибка добавления в коллекцию"); } } }