Allow error message to be formatted

This commit is contained in:
SirLynix
2023-08-14 23:16:37 +02:00
committed by Jérôme Leclercq
parent 25957c4b7f
commit a741672a51
119 changed files with 707 additions and 490 deletions

View File

@@ -179,7 +179,7 @@ namespace Nz
{
SocketError errorCode;
if (!SocketImpl::SetBlocking(m_handle, m_isBlockingEnabled, &errorCode))
NazaraWarning("Failed to set socket blocking mode (0x" + NumberToString(UnderlyingCast(errorCode), 16) + ')');
NazaraWarning("failed to set socket blocking mode ({0:#x})", UnderlyingCast(errorCode));
}
/*!
@@ -201,7 +201,7 @@ namespace Nz
{
SocketImpl::Close(handle);
NazaraError("Failed to open a dual-stack socket: " + std::string(ErrorToString(m_lastError)));
NazaraError("failed to open a dual-stack socket: {0}", std::string(ErrorToString(m_lastError)));
return false;
}

View File

@@ -39,7 +39,7 @@ namespace Nz
if (!m_library.IsLoaded())
{
NazaraError("failed to load libcurl: " + m_library.GetLastError());
NazaraError("failed to load libcurl: {0}", m_library.GetLastError());
return false;
}

View File

@@ -96,7 +96,7 @@ namespace Nz
if (peerId >= m_peers.size())
{
NazaraError("Insufficient peers");
NazaraError("insufficient peers");
return nullptr;
}
@@ -168,7 +168,7 @@ namespace Nz
if (peerCount > ENetConstants::ENetProtocol_MaximumPeerId)
{
NazaraError("Peer count exceeds maximum peer count supported by protocol (" + NumberToString(ENetConstants::ENetProtocol_MaximumPeerId) + ")");
NazaraError("peer count exceeds maximum peer count supported by protocol ({0})", UnderlyingCast(ENetConstants::ENetProtocol_MaximumPeerId));
return false;
}
@@ -338,7 +338,7 @@ namespace Nz
{
if (m_socket.Bind(address) != SocketState::Bound)
{
NazaraError("Failed to bind address " + address.ToString());
NazaraError("failed to bind address {0}", address.ToString());
return false;
}
}

View File

@@ -94,7 +94,7 @@ namespace Nz
return m_ipv6 == LoopbackIpV6.m_ipv6; // Only compare the ip value
}
NazaraInternalError("Invalid protocol for IpAddress (0x" + NumberToString(UnderlyingCast(m_protocol), 16) + ')');
NazaraInternalError("Invalid protocol for IpAddress ({0:#x})", UnderlyingCast(m_protocol));
return false;
}

View File

@@ -61,7 +61,7 @@ namespace Nz
if (epoll_ctl(m_handle, EPOLL_CTL_ADD, socket, &entry) != 0)
{
NazaraError("Failed to add socket to epoll structure (errno " + NumberToString(errno) + ": " + Error::GetLastSystemError() + ')');
NazaraError("failed to add socket to epoll structure (errno {0}: {1})", errno, Error::GetLastSystemError());
return false;
}

View File

@@ -178,7 +178,7 @@ namespace Nz
}
default:
NazaraInternalError("Unhandled ip protocol (0x" + NumberToString(UnderlyingCast(ipAddress.GetProtocol()), 16) + ')');
NazaraInternalError("Unhandled ip protocol ({0:#x})", UnderlyingCast(ipAddress.GetProtocol()));
break;
}
}

View File

@@ -198,7 +198,7 @@ namespace Nz
if (waitError != SocketError::NoError)
{
if (waitError != SocketError::Interrupted) //< Do not log interrupted error
NazaraError("SocketPoller encountered an error (code: 0x" + NumberToString(UnderlyingCast(waitError), 16) + "): " + ErrorToString(waitError));
NazaraError("SocketPoller encountered an error (code: {0:#x}): {1}", UnderlyingCast(waitError), ErrorToString(waitError));
return 0;
}

View File

@@ -187,7 +187,7 @@ namespace Nz
break;
}
NazaraInternalError("Unexpected socket state (0x" + NumberToString(UnderlyingCast(m_state), 16) + ')');
NazaraInternalError("Unexpected socket state ({0:#x})", UnderlyingCast(m_state));
return m_state;
}
@@ -479,7 +479,7 @@ namespace Nz
break;
}
NazaraInternalError("Unhandled socket state (0x" + NumberToString(UnderlyingCast(m_state), 16) + ')');
NazaraInternalError("Unhandled socket state ({0:#x})", UnderlyingCast(m_state));
return m_state;
}
@@ -516,10 +516,10 @@ namespace Nz
SocketError errorCode;
if (!SocketImpl::SetNoDelay(m_handle, m_isLowDelayEnabled, &errorCode))
NazaraWarning("Failed to set socket no delay mode (0x" + NumberToString(UnderlyingCast(errorCode), 16) + ')');
NazaraWarning("failed to set socket no delay mode ({0:#x})", UnderlyingCast(errorCode));
if (!SocketImpl::SetKeepAlive(m_handle, m_isKeepAliveEnabled, m_keepAliveTime, m_keepAliveInterval, &errorCode))
NazaraWarning("Failed to set socket keep alive mode (0x" + NumberToString(UnderlyingCast(errorCode), 16) + ')');
NazaraWarning("failed to set socket keep alive mode ({0:#x})", UnderlyingCast(errorCode));
m_peerAddress = IpAddress::Invalid;
m_openMode = OpenMode_ReadWrite;

View File

@@ -160,7 +160,7 @@ namespace Nz
int errorCode = WSAStartup(MAKEWORD(2, 2), &s_WSA);
if (errorCode != 0)
{
NazaraError("Failed to initialize Windows Socket 2.2: " + Error::GetLastSystemError(errorCode));
NazaraError("failed to initialize Windows Socket 2.2: {0}", Error::GetLastSystemError(errorCode));
return false;
}

View File

@@ -91,7 +91,7 @@ namespace Nz
fd_set& targetSet = (i == 0) ? m_readSockets : m_writeSockets;
if (targetSet.fd_count > FD_SETSIZE)
{
NazaraError("Socket count exceeding hard-coded FD_SETSIZE (" + NumberToString(FD_SETSIZE) + ")");
NazaraError("Socket count exceeding hard-coded FD_SETSIZE ({0})", FD_SETSIZE);
return false;
}