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.traits;
import std.typecons; import std.typecons;
import tanya.memory; import tanya.memory;
import tanya.os.error;
/// Value returned by socket operations on error. /// Value returned by socket operations on error.
enum int socketError = -1; enum int socketError = -1;
@ -581,9 +582,7 @@ enum AddressFamily : int
inet6 = 10, /// IP version 6. inet6 = 10, /// IP version 6.
} }
/** deprecated("Use tanya.os.error.ErrorCode.ErrorNo instead")
* Error codes for $(D_PSYMBOL Socket).
*/
enum SocketError : int enum SocketError : int
{ {
/// Unknown error. /// Unknown error.
@ -621,7 +620,7 @@ enum SocketError : int
*/ */
class SocketException : Exception class SocketException : Exception
{ {
const SocketError error = SocketError.unknown; const ErrorCode.ErrorNo error = ErrorCode.ErrorNo.success;
/** /**
* Params: * Params:
@ -637,7 +636,7 @@ class SocketException : Exception
{ {
super(msg, file, line, next); super(msg, file, line, next);
foreach (member; EnumMembers!SocketError) foreach (member; EnumMembers!(ErrorCode.ErrorNo))
{ {
if (member == lastError) if (member == lastError)
{ {
@ -647,24 +646,24 @@ class SocketException : Exception
} }
if (lastError == ENOMEM) if (lastError == ENOMEM)
{ {
error = SocketError.noBufferSpaceAvailable; error = ErrorCode.ErrorNo.noBufferSpace;
} }
else if (lastError == EMFILE) else if (lastError == EMFILE)
{ {
error = SocketError.tooManyOpenSockets; error = ErrorCode.ErrorNo.tooManyDescriptors;
} }
else version (linux) else version (linux)
{ {
if (lastError == ENOSR) if (lastError == ENOSR)
{ {
error = SocketError.networkDown; error = ErrorCode.ErrorNo.networkDown;
} }
} }
else version (Posix) else version (Posix)
{ {
if (lastError == EPROTO) 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, * Source: $(LINK2 https://github.com/caraus-ecms/tanya/blob/master/source/tanya/sys/windows/error.d,
* tanya/sys/windows/error.d) * tanya/sys/windows/error.d)
*/ */
deprecated("Use core.sys.windows.winerror instead")
module tanya.sys.windows.error; module tanya.sys.windows.error;
version (Windows): version (Windows):