Replace SocketError with ErrorCode.ErrorNo

This commit is contained in:
Eugen Wissner 2018-04-25 12:59:38 +02:00
parent 3f9b500e20
commit b94da1f58a
2 changed files with 11 additions and 11 deletions

View File

@ -21,6 +21,7 @@ public import std.socket : SocketOption, SocketOptionLevel;
import std.traits;
import std.typecons;
import tanya.memory;
import tanya.os.error;
/// Value returned by socket operations on error.
enum int socketError = -1;
@ -581,9 +582,7 @@ enum AddressFamily : int
inet6 = 10, /// IP version 6.
}
/**
* Error codes for $(D_PSYMBOL Socket).
*/
deprecated("Use tanya.os.error.ErrorCode.ErrorNo instead")
enum SocketError : int
{
/// Unknown error.
@ -621,7 +620,7 @@ enum SocketError : int
*/
class SocketException : Exception
{
const SocketError error = SocketError.unknown;
const ErrorCode.ErrorNo error = ErrorCode.ErrorNo.success;
/**
* Params:
@ -637,7 +636,7 @@ class SocketException : Exception
{
super(msg, file, line, next);
foreach (member; EnumMembers!SocketError)
foreach (member; EnumMembers!(ErrorCode.ErrorNo))
{
if (member == lastError)
{
@ -647,24 +646,24 @@ class SocketException : Exception
}
if (lastError == ENOMEM)
{
error = SocketError.noBufferSpaceAvailable;
error = ErrorCode.ErrorNo.noBufferSpace;
}
else if (lastError == EMFILE)
{
error = SocketError.tooManyOpenSockets;
error = ErrorCode.ErrorNo.tooManyDescriptors;
}
else version (linux)
{
if (lastError == ENOSR)
{
error = SocketError.networkDown;
error = ErrorCode.ErrorNo.networkDown;
}
}
else version (Posix)
{
if (lastError == EPROTO)
{
error = SocketError.networkDown;
error = ErrorCode.ErrorNo.networkDown;
}
}
}

View File

@ -10,6 +10,7 @@
* Source: $(LINK2 https://github.com/caraus-ecms/tanya/blob/master/source/tanya/sys/windows/error.d,
* tanya/sys/windows/error.d)
*/
deprecated("Use core.sys.windows.winerror instead")
module tanya.sys.windows.error;
version (Windows):
@ -77,7 +78,7 @@ enum
WSA_E_NO_MORE = WSABASEERR + 110,
WSA_E_CANCELLED = WSABASEERR + 111,
WSAEREFUSED = WSABASEERR + 112,
WSAHOST_NOT_FOUND = WSABASEERR + 1001,
WSATRY_AGAIN = WSABASEERR + 1002,
WSANO_RECOVERY = WSABASEERR + 1003,
@ -111,4 +112,4 @@ enum
WSA_QOS_ESDMODEOBJ = WSABASEERR + 1029,
WSA_QOS_ESHAPERATEOBJ = WSABASEERR + 1030,
WSA_QOS_RESERVED_PETYPE = WSABASEERR + 1031,
}
}