This source file includes following definitions.
- MapSystemError
#include "net/base/net_errors.h"
#include <winsock2.h>
#include "base/logging.h"
namespace net {
Error MapSystemError(int os_error) {
if (os_error != 0)
DVLOG(2) << "Error " << os_error;
switch (os_error) {
case WSAEWOULDBLOCK:
case WSA_IO_PENDING:
return ERR_IO_PENDING;
case WSAEACCES:
return ERR_ACCESS_DENIED;
case WSAENETDOWN:
return ERR_INTERNET_DISCONNECTED;
case WSAETIMEDOUT:
return ERR_TIMED_OUT;
case WSAECONNRESET:
case WSAENETRESET:
return ERR_CONNECTION_RESET;
case WSAECONNABORTED:
return ERR_CONNECTION_ABORTED;
case WSAECONNREFUSED:
return ERR_CONNECTION_REFUSED;
case WSA_IO_INCOMPLETE:
case WSAEDISCON:
return ERR_CONNECTION_CLOSED;
case WSAEISCONN:
return ERR_SOCKET_IS_CONNECTED;
case WSAEHOSTUNREACH:
case WSAENETUNREACH:
return ERR_ADDRESS_UNREACHABLE;
case WSAEADDRNOTAVAIL:
return ERR_ADDRESS_INVALID;
case WSAEMSGSIZE:
return ERR_MSG_TOO_BIG;
case WSAENOTCONN:
return ERR_SOCKET_NOT_CONNECTED;
case WSAEAFNOSUPPORT:
return ERR_ADDRESS_UNREACHABLE;
case WSAEINVAL:
return ERR_INVALID_ARGUMENT;
case WSAEADDRINUSE:
return ERR_ADDRESS_IN_USE;
case ERROR_FILE_NOT_FOUND:
return ERR_FILE_NOT_FOUND;
case ERROR_PATH_NOT_FOUND:
return ERR_FILE_NOT_FOUND;
case ERROR_TOO_MANY_OPEN_FILES:
return ERR_INSUFFICIENT_RESOURCES;
case ERROR_ACCESS_DENIED:
return ERR_ACCESS_DENIED;
case ERROR_INVALID_HANDLE:
return ERR_INVALID_HANDLE;
case ERROR_NOT_ENOUGH_MEMORY:
return ERR_OUT_OF_MEMORY;
case ERROR_OUTOFMEMORY:
return ERR_OUT_OF_MEMORY;
case ERROR_WRITE_PROTECT:
return ERR_ACCESS_DENIED;
case ERROR_SHARING_VIOLATION:
return ERR_ACCESS_DENIED;
case ERROR_LOCK_VIOLATION:
return ERR_ACCESS_DENIED;
case ERROR_HANDLE_EOF:
return ERR_FAILED;
case ERROR_HANDLE_DISK_FULL:
return ERR_FILE_NO_SPACE;
case ERROR_FILE_EXISTS:
return ERR_FILE_EXISTS;
case ERROR_INVALID_PARAMETER:
return ERR_INVALID_ARGUMENT;
case ERROR_BUFFER_OVERFLOW:
return ERR_FILE_PATH_TOO_LONG;
case ERROR_DISK_FULL:
return ERR_FILE_NO_SPACE;
case ERROR_CALL_NOT_IMPLEMENTED:
return ERR_NOT_IMPLEMENTED;
case ERROR_INVALID_NAME:
return ERR_INVALID_ARGUMENT;
case ERROR_DIR_NOT_EMPTY:
return ERR_FAILED;
case ERROR_BUSY:
return ERR_ACCESS_DENIED;
case ERROR_ALREADY_EXISTS:
return ERR_FILE_EXISTS;
case ERROR_FILENAME_EXCED_RANGE:
return ERR_FILE_PATH_TOO_LONG;
case ERROR_FILE_TOO_LARGE:
return ERR_FILE_NO_SPACE;
case ERROR_VIRUS_INFECTED:
return ERR_FILE_VIRUS_INFECTED;
case ERROR_IO_DEVICE:
return ERR_ACCESS_DENIED;
case ERROR_POSSIBLE_DEADLOCK:
return ERR_ACCESS_DENIED;
case ERROR_BAD_DEVICE:
return ERR_INVALID_ARGUMENT;
case ERROR_BROKEN_PIPE:
return ERR_CONNECTION_RESET;
case ERROR_SUCCESS:
return OK;
default:
LOG(WARNING) << "Unknown error " << os_error
<< " mapped to net::ERR_FAILED";
return ERR_FAILED;
}
}
}