feat: add some low level error handling

This commit is contained in:
k0t9i
2023-10-19 10:04:52 +04:00
parent 641e20e82a
commit 2e025fd0cf
9 changed files with 203 additions and 74 deletions

View File

@@ -40,7 +40,7 @@ public:
if (m_Pipe == INVALID_HANDLE_VALUE)
{
throw RuntimeException(std::format(L"cannot create the pipe {}: {}", m_PipeName, GetLastError()));
throw CriticalRuntimeException(std::format(L"cannot create the pipe {}: {}", m_PipeName, GetLastError()));
}
}
else
@@ -83,13 +83,13 @@ public:
if (!overlappedResult)
{
m_Connected = false;
throw RuntimeException(std::format(L"cannot get overlapped result for the pipe {} when writing", m_PipeName));
throw CriticalRuntimeException(std::format(L"cannot get overlapped result for the pipe {} when writing", m_PipeName));
}
}
else
{
m_Connected = false;
throw RuntimeException(std::format(L"cannot write to the pipe {}: {}", m_PipeName, lastError));
throw CriticalRuntimeException(std::format(L"cannot write to the pipe {}: {}", m_PipeName, lastError));
}
}
}
@@ -116,13 +116,13 @@ public:
if (!overlappedResult)
{
m_Connected = false;
throw RuntimeException(std::format(L"cannot get overlapped result for the pipe {} when reading", m_PipeName));
throw CriticalRuntimeException(std::format(L"cannot get overlapped result for the pipe {} when reading", m_PipeName));
}
}
else
{
m_Connected = false;
throw RuntimeException(std::format(L"cannot read from the pipe {}: {}", m_PipeName, lastError));
throw CriticalRuntimeException(std::format(L"cannot read from the pipe {}: {}", m_PipeName, lastError));
}
}
@@ -151,7 +151,7 @@ private:
const bool connected = ConnectNamedPipe(m_Pipe, &m_ConntectingOverlapped) == 0;
if (!connected)
{
throw RuntimeException(std::format(L"cannot connect the pipe {}: {}", m_PipeName, GetLastError()));
throw CriticalRuntimeException(std::format(L"cannot connect the pipe {}: {}", m_PipeName, GetLastError()));
}
switch (GetLastError())
@@ -164,7 +164,7 @@ private:
if (SetEvent(m_ConntectingOverlapped.hEvent))
break;
default:
throw RuntimeException(std::format(L"an error has occurred when connecting to the pipe ""{}"": {}", m_PipeName, GetLastError()));
throw CriticalRuntimeException(std::format(L"an error has occurred when connecting to the pipe ""{}"": {}", m_PipeName, GetLastError()));
}
}
@@ -175,7 +175,7 @@ private:
overlapped.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
if (overlapped.hEvent == NULL)
{
throw RuntimeException(std::format(L"cannot create overlapped for the pipe {}: {}", m_PipeName, GetLastError()));
throw CriticalRuntimeException(std::format(L"cannot create overlapped for the pipe {}: {}", m_PipeName, GetLastError()));
}
overlapped.Offset = 0;
overlapped.OffsetHigh = 0;