коммит1

This commit is contained in:
Kirill 2023-12-25 22:22:47 +04:00
parent 47cf7a6743
commit baa9a24290
3 changed files with 4 additions and 51 deletions

View File

@ -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) { }
}
}

View File

@ -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) { }
}
}

View File

@ -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("Ошибка добавления в коллекцию");
}
}
}