[*] improved network error reporting

This commit is contained in:
Reece Wilson 2023-04-26 20:13:17 +01:00
parent 044fb5b7e4
commit b8540c77a7
3 changed files with 30 additions and 0 deletions

View File

@ -32,6 +32,7 @@ namespace Aurora::IO::Net
eEndpointRefused,
eServiceRefused,
eServiceTaken,
eBrokenAIOPipe,
eUnknown
));
}

View File

@ -449,6 +449,15 @@ namespace Aurora::IO::Net
const NetError &SocketBase::GetError()
{
if (this->error_.netError == ENetworkError::kEnumInvalid)
{
if (this->socketChannel_.inputChannel.pNetReadTransaction &&
this->socketChannel_.inputChannel.pNetReadTransaction->Failed())
{
NetError_SetOsError(this->error_, this->socketChannel_.inputChannel.pNetReadTransaction->GetOSErrorCode());
}
}
return this->error_;
}

View File

@ -11,6 +11,7 @@
#include "AuNetWorker.hpp"
#include "AuNetSocketChannel.hpp"
#include <Source/IO/AuIOPipeProcessor.hpp>
#include "AuNetError.hpp"
namespace Aurora::IO::Net
{
@ -128,6 +129,25 @@ namespace Aurora::IO::Net
void SocketChannelInput::OnPipeFailureEvent()
{
NetError error;
bool bSetError {};
if (this->pNetReadTransaction)
{
if (this->pNetReadTransaction->Failed())
{
NetError_SetOsError(error, this->pNetReadTransaction->GetOSErrorCode());
bSetError = true;
}
}
if (!bSetError)
{
error = ENetworkError::eBrokenAIOPipe;
}
this->pParent_->SendErrorNoStream(error);
DecrementWorker();
this->pNetReader.reset();
this->pNetReadTransaction.reset();