Исправление ошибок

This commit is contained in:
ShuryginDima 2024-05-20 15:31:50 +03:00
parent bf12e1a9bf
commit b647c5bf83
4 changed files with 4 additions and 25 deletions

View File

@ -70,7 +70,7 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
public int Insert(T obj, int position) public int Insert(T obj, int position)
{ {
if (position < 0 || position >= Count) if (position < 0)
{ {
return -1; return -1;
} }
@ -103,7 +103,7 @@ public class MassiveGenericObjects<T> : ICollectionGenericObjects<T>
{ {
try try
{ {
T obj = _collection[position]; T? obj = _collection[position];
if (obj == null) throw new ObjectNotFoundException(position); if (obj == null) throw new ObjectNotFoundException(position);
_collection[position] = null; _collection[position] = null;
return obj; return obj;

View File

@ -78,7 +78,7 @@ public partial class FormPlaneCollection : Form
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show("Объект не был добавлен"); MessageBox.Show(ex.Message);
_logger.LogError("Ошибка: {Message}", ex.Message); _logger.LogError("Ошибка: {Message}", ex.Message);
} }
} }
@ -110,7 +110,7 @@ public partial class FormPlaneCollection : Form
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show("Не удалось удалить объект"); MessageBox.Show(ex.Message);
_logger.LogError("Ошибка: {Message}", ex.Message); _logger.LogError("Ошибка: {Message}", ex.Message);
} }

View File

@ -35,10 +35,4 @@
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Update="nlog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project> </Project>

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true" internalLogLevel="Info">
<targets>
<target xsi:type="File" name="tofile" fileName="carlog-${shortdate}.log" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="tofile" />
</rules>
</nlog>
</configuration>