This source file includes following definitions.
- MapSystemError
#include "net/base/net_errors.h"
#include <errno.h>
#include <stdlib.h>
#include <string>
#include <unistd.h>
#include "base/logging.h"
#include "base/strings/stringprintf.h"
namespace net {
Error MapSystemError(int os_error) {
if (os_error != 0)
DVLOG(2) << "Error " << os_error;
switch (os_error) {
case EAGAIN:
#if EWOULDBLOCK != EAGAIN
case EWOULDBLOCK:
#endif
return ERR_IO_PENDING;
case EACCES:
return ERR_ACCESS_DENIED;
case ENETDOWN:
return ERR_INTERNET_DISCONNECTED;
case ETIMEDOUT:
return ERR_TIMED_OUT;
case ECONNRESET:
case ENETRESET:
case EPIPE:
return ERR_CONNECTION_RESET;
case ECONNABORTED:
return ERR_CONNECTION_ABORTED;
case ECONNREFUSED:
return ERR_CONNECTION_REFUSED;
case EHOSTUNREACH:
case EHOSTDOWN:
case ENETUNREACH:
case EAFNOSUPPORT:
return ERR_ADDRESS_UNREACHABLE;
case EADDRNOTAVAIL:
return ERR_ADDRESS_INVALID;
case EMSGSIZE:
return ERR_MSG_TOO_BIG;
case ENOTCONN:
return ERR_SOCKET_NOT_CONNECTED;
case EISCONN:
return ERR_SOCKET_IS_CONNECTED;
case EINVAL:
return ERR_INVALID_ARGUMENT;
case EADDRINUSE:
return ERR_ADDRESS_IN_USE;
case E2BIG:
return ERR_INVALID_ARGUMENT;
case EBADF:
return ERR_INVALID_HANDLE;
case EBUSY:
return ERR_INSUFFICIENT_RESOURCES;
case ECANCELED:
return ERR_ABORTED;
case EDEADLK:
return ERR_INSUFFICIENT_RESOURCES;
case EDQUOT:
return ERR_FILE_NO_SPACE;
case EEXIST:
return ERR_FILE_EXISTS;
case EFAULT:
return ERR_INVALID_ARGUMENT;
case EFBIG:
return ERR_FILE_TOO_BIG;
case EISDIR:
return ERR_ACCESS_DENIED;
case ENAMETOOLONG:
return ERR_FILE_PATH_TOO_LONG;
case ENFILE:
return ERR_INSUFFICIENT_RESOURCES;
case ENOBUFS:
return ERR_OUT_OF_MEMORY;
case ENODEV:
return ERR_INVALID_ARGUMENT;
case ENOENT:
return ERR_FILE_NOT_FOUND;
case ENOLCK:
return ERR_INSUFFICIENT_RESOURCES;
case ENOMEM:
return ERR_OUT_OF_MEMORY;
case ENOSPC:
return ERR_FILE_NO_SPACE;
case ENOSYS:
return ERR_NOT_IMPLEMENTED;
case ENOTDIR:
return ERR_FILE_NOT_FOUND;
case ENOTSUP:
return ERR_NOT_IMPLEMENTED;
case EPERM:
return ERR_ACCESS_DENIED;
case EROFS:
return ERR_ACCESS_DENIED;
case ETXTBSY:
return ERR_ACCESS_DENIED;
case EUSERS:
return ERR_INSUFFICIENT_RESOURCES;
case EMFILE:
return ERR_INSUFFICIENT_RESOURCES;
case 0:
return OK;
default:
LOG(WARNING) << "Unknown error " << os_error
<< " mapped to net::ERR_FAILED";
return ERR_FAILED;
}
}
}