1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "net/base/net_errors.h"
12 #include "base/logging.h"
13 #include "base/strings/stringprintf.h"
17 Error
MapSystemError(logging::SystemErrorCode os_error
) {
19 DVLOG(2) << "Error " << os_error
;
21 // There are numerous posix error codes, but these are the ones we thus far
25 #if EWOULDBLOCK != EAGAIN
28 return ERR_IO_PENDING
;
30 return ERR_ACCESS_DENIED
;
32 return ERR_INTERNET_DISCONNECTED
;
36 case ENETRESET
: // Related to keep-alive.
38 return ERR_CONNECTION_RESET
;
40 return ERR_CONNECTION_ABORTED
;
42 return ERR_CONNECTION_REFUSED
;
47 return ERR_ADDRESS_UNREACHABLE
;
49 return ERR_ADDRESS_INVALID
;
51 return ERR_MSG_TOO_BIG
;
53 return ERR_SOCKET_NOT_CONNECTED
;
55 return ERR_SOCKET_IS_CONNECTED
;
57 return ERR_INVALID_ARGUMENT
;
59 return ERR_ADDRESS_IN_USE
;
60 case E2BIG
: // Argument list too long.
61 return ERR_INVALID_ARGUMENT
;
62 case EBADF
: // Bad file descriptor.
63 return ERR_INVALID_HANDLE
;
64 case EBUSY
: // Device or resource busy.
65 return ERR_INSUFFICIENT_RESOURCES
;
66 case ECANCELED
: // Operation canceled.
68 case EDEADLK
: // Resource deadlock avoided.
69 return ERR_INSUFFICIENT_RESOURCES
;
70 case EDQUOT
: // Disk quota exceeded.
71 return ERR_FILE_NO_SPACE
;
72 case EEXIST
: // File exists.
73 return ERR_FILE_EXISTS
;
74 case EFAULT
: // Bad address.
75 return ERR_INVALID_ARGUMENT
;
76 case EFBIG
: // File too large.
77 return ERR_FILE_TOO_BIG
;
78 case EISDIR
: // Operation not allowed for a directory.
79 return ERR_ACCESS_DENIED
;
80 case ENAMETOOLONG
: // Filename too long.
81 return ERR_FILE_PATH_TOO_LONG
;
82 case ENFILE
: // Too many open files in system.
83 return ERR_INSUFFICIENT_RESOURCES
;
84 case ENOBUFS
: // No buffer space available.
85 return ERR_OUT_OF_MEMORY
;
86 case ENODEV
: // No such device.
87 return ERR_INVALID_ARGUMENT
;
88 case ENOENT
: // No such file or directory.
89 return ERR_FILE_NOT_FOUND
;
90 case ENOLCK
: // No locks available.
91 return ERR_INSUFFICIENT_RESOURCES
;
92 case ENOMEM
: // Not enough space.
93 return ERR_OUT_OF_MEMORY
;
94 case ENOSPC
: // No space left on device.
95 return ERR_FILE_NO_SPACE
;
96 case ENOSYS
: // Function not implemented.
97 return ERR_NOT_IMPLEMENTED
;
98 case ENOTDIR
: // Not a directory.
99 return ERR_FILE_NOT_FOUND
;
100 case ENOTSUP
: // Operation not supported.
101 return ERR_NOT_IMPLEMENTED
;
102 case EPERM
: // Operation not permitted.
103 return ERR_ACCESS_DENIED
;
104 case EROFS
: // Read-only file system.
105 return ERR_ACCESS_DENIED
;
106 case ETXTBSY
: // Text file busy.
107 return ERR_ACCESS_DENIED
;
108 case EUSERS
: // Too many users.
109 return ERR_INSUFFICIENT_RESOURCES
;
110 case EMFILE
: // Too many open files.
111 return ERR_INSUFFICIENT_RESOURCES
;
116 LOG(WARNING
) << "Unknown error " << os_error
117 << " mapped to net::ERR_FAILED";