7лаба

This commit is contained in:
AnnaLioness 2023-12-01 21:36:23 +04:00
parent 11cf233e44
commit 2b67952e64

View File

@ -148,18 +148,18 @@ public void SaveData(string filename)
{ {
if (!File.Exists(filename)) if (!File.Exists(filename))
{ {
throw new Exception("Файл не найден"); throw new FileNotFoundException("Файл не найден");
} }
using (StreamReader sr = new StreamReader(filename)) using (StreamReader sr = new StreamReader(filename))
{ {
string str = sr.ReadLine(); string str = sr.ReadLine();
if (str == null || str.Length == 0) if (str == null || str.Length == 0)
{ {
throw new Exception("Нет данных для загрузки"); throw new NullReferenceException("Нет данных для загрузки");
} }
if (!str.StartsWith("ShipStorage")) if (!str.StartsWith("ShipStorage"))
{ {
throw new Exception("Неверный формат данных"); throw new FormatException("Неверный формат данных");
} }
_shipStorages.Clear(); _shipStorages.Clear();
@ -190,7 +190,7 @@ public void SaveData(string filename)
} }
catch (ApplicationException ex) catch (ApplicationException ex)
{ {
throw new Exception($"Ошибка добавления в коллекцию: {ex.Message}"); throw new ApplicationException($"Ошибка добавления в коллекцию: {ex.Message}");
} }
} }
} }