exeptions 2, laba 7, 7'th demand
This commit is contained in:
parent
da90b95309
commit
e5ef38acf5
@ -64,15 +64,15 @@ namespace Laba1Loco
|
|||||||
{
|
{
|
||||||
if (!File.Exists(filename))
|
if (!File.Exists(filename))
|
||||||
{
|
{
|
||||||
throw new Exception("Файл не найден");
|
throw new FileNotFoundException("Файл не найден");
|
||||||
}
|
}
|
||||||
using (StreamReader sr = new(filename))
|
using (StreamReader sr = new(filename))
|
||||||
{
|
{
|
||||||
string s = sr.ReadLine();
|
string s = sr.ReadLine();
|
||||||
if (s == null || s.Length == 0)
|
if (s == null || s.Length == 0)
|
||||||
throw new Exception("Нет данных для загрузки");
|
throw new NullReferenceException("Нет данных для загрузки");
|
||||||
if (!s.StartsWith("TrainStorage"))//если нет такой записи, то это не те данные
|
if (!s.StartsWith("TrainStorage"))//если нет такой записи, то это не те данные
|
||||||
throw new Exception("Неверный формат данных");
|
throw new FormatException("Неверный формат данных");
|
||||||
_trainStorages.Clear();
|
_trainStorages.Clear();
|
||||||
s = sr.ReadLine();
|
s = sr.ReadLine();
|
||||||
while (s != null && s.Length != 0)
|
while (s != null && s.Length != 0)
|
||||||
@ -96,7 +96,7 @@ namespace Laba1Loco
|
|||||||
}
|
}
|
||||||
catch (ApplicationException ex)
|
catch (ApplicationException ex)
|
||||||
{
|
{
|
||||||
throw new Exception($"Ошибка добавления в коллекцию: {ex.Message}");
|
throw new ApplicationException($"Ошибка добавления в коллекцию: {ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user